fix logic in Thread.join(long)

This commit is contained in:
Joel Dice 2009-06-04 18:07:00 -06:00
parent 44e3ee5bd7
commit a064c744f4

View File

@ -265,10 +265,12 @@ public class Thread implements Runnable {
public synchronized void join(long milliseconds) throws InterruptedException
{
long then = System.currentTimeMillis();
long remaining = milliseconds;
while (getState() != State.TERMINATED) {
wait();
wait(remaining);
if (System.currentTimeMillis() - then >= milliseconds) {
remaining = milliseconds - (System.currentTimeMillis() - then);
if (remaining <= 0) {
break;
}
}