• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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.
 
What's wrong? Where are you going? Stop! Read this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic