• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread and Synchronization

 
Buhi Mume
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This code basically
1. runs Thread A, then waits until B completes
2. runs Thread B until completion, then notifies A to continue
3. continues Thread A until completion

I am trying to modify the code so that
1. runs Thread A, then waits until B completes
2. runs Thread B (half way), then notifies A to run, then waits until Thread B completes
3. continues Thread A until completion, then notifies B to continue
4. continues Thread B until completion
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving, not surprisingly, to "Threads and Synchronization."
 
Promod kumar
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if this will answer your question. Below is the code that does something similar where you have somestuff done in thread1 and then somestuff done in step2 and then back to thread1 etc. (There are some exceptions where the following will not work, in the case the notify() in Wait1 is triggered before wait() in Wait2.)


Let me know if this helps or if there are any issues with this program. Experts, let me know if there is a better way of doing this.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!