• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Thread and Synchronization

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving, not surprisingly, to "Threads and Synchronization."
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic