Stoping All the Threads in Thread Pool

  • Thread starter Thread starter Santosh
  • Start date Start date
S

Santosh

Hi,
I have a requirement while using ThreadPool class.
I am creating n number of threads using ThreadPool class, using
WaitCallback
method. In this Method I want to stop all the threads started from
main method using ThreadPool.
Is it possible? If yes, how?

Thanks in advance.
Regards,
Santosh L N
 
Hi Santosh,

I don't think that it is possible at all because threads are managed by pool
which won't let you mess with them.
 
Thanks Miha,
My actual problem is, I am creating n number of threads in an array of
Thread class, and I am stopping all the running threads on fail of any
single thread.
The problem is I have no control over CPU usage, it goes up to 100%.
In this case I think, I need to end up with writing my own ThreadPool
class. Is there any better way of solving my problem?

Santosh L N
 
Hi Santosh,

Santosh said:
Thanks Miha,
My actual problem is, I am creating n number of threads in an array of
Thread class, and I am stopping all the running threads on fail of any
single thread.
The problem is I have no control over CPU usage, it goes up to 100%.
In this case I think, I need to end up with writing my own ThreadPool
class. Is there any better way of solving my problem?

You'll never have control over CPU usage.
You might set thread's priority (Thread.Priority) and that's pretty much it.
Note that even a thread with Lowest priority will push cpu usage to 100% but
will let other threads eat more cpu cycles.
 
Back
Top