This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multiple joins with timeouts

 
Carey Brown
Ranch Hand
Pie
Posts: 1335
15
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since neither thread ever finishes, the joins run consecutively. You wait 1 minute in the first join. Then you issue the second join which waits 1 minute.

Join is not your solution. Try wait/notify.

With a max of 60000 milliseconds. You can wait up to 30 seconds for the first thread to notify you and decrement the max wait time by how long it actually took. Then you can wait up to "what is left" milliseconds for the second thread to notify you.

Etc.

Ed
 
Carey Brown
Ranch Hand
Pie
Posts: 1335
15
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Edward Harned wrote:Since neither thread ever finishes...


This is not exactly the case. If, while the joins are pending, the files are created, then the ExistsThread will return.

Thanks for the reminder about wait/notify. I'll re-familiarize myself with it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic