A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Stan James:
After the join() you know the Runnable is done. Can you wait that long to check the value? Also look into Future which is just for this kind of thing.
If you need to sync up on the variable before the Runnable is done things get trickier. Wait and notify come to mind, a queue might be interesting.
BTW: t.start() followed by t.join() kinda defeats the point of threads. Can we assume you really wanted to do more stuff in between these but left it out for a short example?
[ July 31, 2006: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
The final action in a thread T1 synchronizes-with any action in another thread T2 that detects that T1 has terminated. T2 may accomplish this by calling T1.isAlive() or T1.join().
The fastest and most reliable components of any system are those that are not there. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|