diff --git a/classpath/java/lang/Thread.java b/classpath/java/lang/Thread.java index e9fa5c05b3..8fc43b457f 100644 --- a/classpath/java/lang/Thread.java +++ b/classpath/java/lang/Thread.java @@ -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; } }