Click to See Complete Forum and Search --> : Consistancy between two threads...


james1982
February 15th, 2006, 02:06 AM
I'm new about vc++ multithreading. im using boost multithreading library.

My application have two threads. one does data collector and another doing precomputation. I'm failed to make the consistancy between data collector and computation threads. Data collector taking very less time than computation thread. programme kicks me out from the program when data collector finish it task. But still, I want to continue with pre-computation to execute the queue instructions.

How can continue with program until both threads successfully finish ?


I appreciate for your valuable response.

- James

philkr
February 15th, 2006, 04:27 AM
You can use WaitForSingleObject() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/waitforsingleobject.asp) with a handle to the computation thread:

// In main thread:
WaitForSingleObject(hComputationThread, INFINITE);
// Now you can exit program