-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.5, 1.1.6, 1.2.0, 1.3.0
-
generic, x86, sparc
-
generic, solaris_2.4, solaris_8, windows_nt
Name: el35337 Date: 06/04/98
//
// Thread.join() completes too early.
//
// The documentation for Thread.join() states:
// "Waits for this thread to die."
//
// "thread died" should imply that the instruction pointer associated with the
// thread never changes again. However, Thread.join() does not implement these semantics.
//
// A thread which has been stopped may not die immediately because a finally clause on its
// stack may be blocked or otherwise delayed for legitimate reasons. However, Thread.join()
// returns immediately for such threads even if the instruction pointer for the thread will change
// subsequently (i.e. more code is executed).
//
// It seems reasonable that Thread.join() should not complete until the thread is truly dead
// as opposed to "almost dead" otherwise the caller cannot make any strong assertions about
// what other concurrent activity may be in progress.
//
// To compile: javac Bug2.java
// To execute: java -classpath .;%CLASSPATH% Bug2
//
public class Bug2
{
static public class SomeRunnable implements Runnable
{
public void run()
{
try {
System.err.println("run() sleep(5000) begins in " + Thread.currentThread().getName());
Thread.sleep(5000);
System.err.println("run() exits in " + Thread.currentThread().getName());
} catch (InterruptedException e) {
} finally {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
}
System.err.println("run() finally clause exits in " + Thread.currentThread().getName());
}
}
}
public static void main(String args[])
{
Thread t1;
try {
t1 = new Thread(new SomeRunnable(), "t1");
t1.start();
Thread.sleep(2000);
t1.stop();
t1.join();
System.err.println("t1.join completes");
} catch (InterruptedException i) {
}
}
}
(Review ID: 32952)
======================================================================
- duplicates
-
JDK-4148125 Thread.join() completes too early
- Closed
-
JDK-4082713 stop signal issued before thread start is lost.
- Closed
-
JDK-4314342 Mechanism for Thread.stop broken. Sparc, compilers 1 and 2.
- Closed
- relates to
-
JDK-4216667 Thread.stop() does not always work (problem with fix for 4145910)
- Closed