|
-
April 27th, 2011, 12:41 PM
#1
Multithreading
Hello,
I have a question and hope to get some helps or approaches from here.
My program has two child threads, thread1 and thread2 spawned from the main thread. when a button from the main thread is clicked, it checks user's selections on three check boxes. The checks can be in any combination, but they always be executed in sequence.
Thread1 is in charge of running three heavy calculations and thread2 is in charge of displaying results immediately after each calculation to the GUI. I have both threads created in main in the suspended states. When the button is clicked, thread1 starts doing his jobs. Once thread1 finishes his first job, it resumes thread2 to update the results to the screen. In the mean while, thread2 continues to do his second job.
The question I have is how do I put thread2 to pause until thread1 finishes his second job, then thread2 can update the results to screen, then continue one in this fashion. I do not want to use busy wait loop, because it will eat up lots of cpu time. What is the best approach here in this case?
Moreover, once thread1 finishes all his tasks, user can input different parameters and restart the calculation again with different selections.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|