Your application is probably hanging because you are filling it to such an extent that all active threads are waiting in line for the queue. (I assume that the source thread expects the work item to complete the queue.)
ThreadPool defaults to 25 * workflows (number of processors) (IIRC).
You probably want to recycle the way you queue. If you put them in the queue, and then exit and exit the stream, you are fine, but the presence of work items that hang in anticipation of other processes is usually poor design; if this is what you are doing, you probably need to use real threads or a completely different design. Using real threads is probably no less a bad idea, because everything that will do (based on what I can guess about your use), you simply create a large number of threads that will not benefit your performance.
The best design may be to have some kind of queue or stack in which several workflows (2-4 depending on the number of processors) add elements and go to work. If an element needs to queue a new element, it simply adds it to the stack (and adds itself back to the stack with some kind of dependency tracking if it needs to wait for another element).
source share