473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Implementing multithreading with functions having parameters

18
Hi,

I am new to working on threading. I need to implement multithreading for calling four functions (each functions are having parameters) in different threads so that i can improve the performance of the software. Can anybody help me with sample code for implementing this?

Thanks,
Anish.
Jun 7 '07 #1
2 1319
Frinavale
9,735 Expert Mod 8TB
Hi,

I am new to working on threading. I need to implement multithreading for calling four functions (each functions are having parameters) in different threads so that i can improve the performance of the software. Can anybody help me with sample code for implementing this?

Thanks,
Anish.
What have you tried so far?
Have you seen the two Sticky links at the top of this forum?
The second Sticky link on important links and answers to commonly asked questions contains a bunch of links to resources that may help you out.

Specifically check out the MSDN Library.

Hope this helps!

-Frinny
Jun 7 '07 #2
chinu
36
What have you tried so far?
Have you seen the two Sticky links at the top of this forum?
The second Sticky link on important links and answers to commonly asked questions contains a bunch of links to resources that may help you out.

Specifically check out the MSDN Library.

Hope this helps!

-Frinny
try something like below
class MyThread
{
public int Data1;
public string Data2;
public void Fn1(object y)
{
Data1 = (int)y;
Console.WriteLine(Data1);
Thread.Sleep(5000);
}
public void Fn2(object x)
{
Data2 = (string)x;
Console.WriteLine(Data2);
}
}

class Program
{
static void Main(string[] args)
{
MyThread w = new MyThread();
w.Data1 = 42;
w.Data2 = "aa";
Thread newThread1 = new Thread(new ParameterizedThreadStart(w.Fn1));
Thread newThread2 = new Thread(new ParameterizedThreadStart(w.Fn2));
newThread1.Start(10);
newThread2.Start("test");
}
}
Jun 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: TazCoder | last post by:
I have a problem with multithreading. The error I keep getting is that findFileButton_Click(...) is not a member function. But when I take the parameters out of the findFileButton_Click(...)...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
15
by: Bernard | last post by:
Hi All, I am not sure if I should be asking this question on clc or clc++. Let me try on both. I hope that this is not too trivial for the brilliant minds over here. I know that OOP questions...
12
by: Winbatch | last post by:
Hi, I'm trying to learn multithreading and it doesn't seem to be working for me. I have a feeling it has to do with the fact that I'm writing to files rather than to printf, but maybe not. ...
6
by: VM | last post by:
I'm trying to add multithreading to my win application but I'm having trouble with the code since the method to be threaded has parameters. How can I add multithreading to a method with parameters?...
5
by: mrkbrndck | last post by:
Please see the code below as I am trying to use multithreading for copying files to a new location in a way that improves performance of the client windows application. The problem occurs when 2...
13
by: Simon Dean | last post by:
Hi, I have a couple of questions. If you don't mind. Sorry, I do get a bit wordy at times. First one just throws some thoughts around hoping for answers :-) 1) Anyone got a theory on the...
2
by: Pradnya Patil | last post by:
hi , I am trying to draw ' html div-tag ' on the screen which will resemble a rectangle through vb.net code. I want it to be drawn faster...so I introduced multithreading using Threadpool. I...
1
by: madankarmukta | last post by:
Hi All, I have the application whose runtime argument will decides how many threads I have to create.All these threads functionality may differ by a step or two.Threads are going to use the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.