473,382 Members | 1,750 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,382 software developers and data experts.

Thread array

how can I create and use a thread array???
Nov 16 '05 #1
1 17939
You mean an array of threads?

My first suggestion is always to look at the ThreadPool class in the
System.Threading namespace. If that won't suit your needs, perhaps you
are trying to do something like the following?

static void Main(string[] args)
{
Thread[] threads = new Thread[5];

for(int i = 0; i < threads.Length; i++)
{
threads[i] = new Thread(new ThreadStart(DoWork));
}

for(int i = 0; i < threads.Length; i++)
{
threads[i].Start();
}

for(int i = 0; i < threads.Length; i++)
{
threads[i].Join();
}

Console.WriteLine("Complete");
}

static void DoWork()
{
Console.WriteLine("DoWork");
}

HTH,

--
Scott
http://www.OdeToCode.com

On Mon, 12 Apr 2004 19:17:10 -0300, "Ricardo" <dr*******@terra.com.br>
wrote:
how can I create and use a thread array???


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: AlexeiOst | last post by:
Everywhere in documentation there are recommendations to use threads from thread pooling for relatively short tasks. As I understand, fetching a page or multiple pages (sometimes up to 50 but not...
13
by: Alvin Bruney | last post by:
I have an array list of queries. The arraylist is variable, anywhere from 10 to 10000 or more. I'd like to spin threads to take chunks of 500 queries out of that array list, no more than 10 threads...
9
by: Víctor | last post by:
Hello, I'm filling a array of System.Diagnostic.Process by using GetProcesses() method. Due to a retard on this method, I do the call using a function and it passing like a delegate to one...
6
by: Daniel | last post by:
i have an array that i want all threads to be able to READ from concurrently, however, at times i want to UPDATE the array. at which point i want all threads that use it to block when they try to...
2
by: objectref | last post by:
hi to all folks, i want to create the following senario: i have a T1 (Thread 1) that acts like http server that receives incoming requests. From that T1, i want to spawn from T1 to Tn thread...
2
by: White Spirit | last post by:
I've read that it is not recommended to use Thread.Suspend and Thread.Resume to control execution of threads and that use of the Monitor class is preferred. I'm writing a server that lets users...
8
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In...
4
by: Adam Benson | last post by:
Hi, We have an app which, every now and then, has very high CPU usage. Profiling under perfmon shows it to be thread #3 which is running at >=95%. I took a process dump and looked at thread #3...
3
by: fniles | last post by:
I am using VB.Net 2005. My main program calls 2 thread, say thread A and B. I would like to use an array (or arraylist) that will be shared and modified by all the main program, thread A and B....
34
by: Creativ | last post by:
Why does Thread class not support IDisposable? It's creating quite some problem. Namely, it can exhaust the resource and you have not control over it.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.