Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
From my limited understanding ThreadPool creates the optimal number of threads and queues incoming "work" if the the optimal number of threads have been created and are in use (working)...

Isn't this the exact same thing as creating a multiThreaded consumer-producer queue? If so what's the need/purpose of creating a managed synchronized thread w/ a queue holding the work/task "IF" I can use a ThreadPool and accomplish the same thing?

Thanks in advance,
-DA
Posted

1 solution

No, of course these are absolutely different things. Thread pool is just the automated thread re-use mechanism. As to the queues used in thread synchronization, it does not really matter how the threads were obtained. Isn't that obvious? Threads are threads; when you set up the thread's properties and are using it already, it works in exact same way, not matter the way you obtained it.

The queuing mechanism and inter-thread invocation is explained in detail in my Tips & Tricks article "Simple Blocking Queue for Thread Communication and Inter-thread Invocation"[^], complete with source code and usage sample. One interesting case is using delegate instances as queue elements, which makes the mechanism of invocation extremely flexible, similar the invocation mechanism used with UI threads with WPF and System.Windows.Forms.

—SA
 
Share this answer
 
v2
Comments
Monjurul Habib 23-Dec-11 15:41pm    
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900