Using threads correctly

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys,

Whenever i need to use threads in my apps, i always
have the same problem of choosing the right kind of
threads to create.
I never know whether to create threads by using:
1) The Thread class, which may create a new os thread
2) A delegate, which uses a thread from the thread pool
3) The ThreadPool, which uses the thread pool as well

Can anyone please shed some light on this subject?

Thanks,
Avi
 
Avi Shilon said:
Whenever i need to use threads in my apps, i always
have the same problem of choosing the right kind of
threads to create.
I never know whether to create threads by using:
1) The Thread class, which may create a new os thread
2) A delegate, which uses a thread from the thread pool
3) The ThreadPool, which uses the thread pool as well

Can anyone please shed some light on this subject?

Or 4) using a thread pool other than the system one.

I would suggest only using the system ThreadPool for short operations
which definitely won't need to use the threadpool themselves - it's
easy to deadlock, as the framework libraries don't say which method
calls block on other thread pool threads.

I would usually advocate a custom thread pool or a new thread.
 
Back
Top