Thread completed state.

  • Thread starter Thread starter objectref
  • Start date Start date
O

objectref

Hi,

is there a way to spawn some threads (not from the thread pool) and knowing
when each of these therads has completed its' job ?

I have thought to put them on a hash and requery their IsAlive or
ThreadState status
but is it another way to do so ?

thanks in advance,

objectref
 
You can create an array of Events and when the thread proc is completed the
event is signaled you can use WaitAny and then from the return value you can
determine which thread has finished its job.

You are not restricted to events here, mutex can also be used.

The whole algorithm would be like this
thread starts a number of threads each thread aquires an mutex or sets an
event from the array. Then main thread calls in the loop WaitAny and
determines which one of the threads is finished.
 
Back
Top