Two Laptop Bag
The moose likes Threads and Synchronization and the fly likes multiple joins with timeouts Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "multiple joins with timeouts" Watch "multiple joins with timeouts" New topic
Author

multiple joins with timeouts

Carey Brown
Ranch Hand

Joined: Nov 19, 2001
Posts: 130

Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 269

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


Ed's latest article: Managing Threads in Android http://coopsoft.com/ar/AndroidArticle.html
Carey Brown
Ranch Hand

Joined: Nov 19, 2001
Posts: 130

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.
 
 
subject: multiple joins with timeouts
 
Threads others viewed
NIO
Want timeout error on hung thread
Image Dimensions
Thread waiting forever,
Countdown timer in java
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture