Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2177057 | 7 | Erik Trimble | P3 | Closed | Fixed | b22 |
JDK-2157868 | 6u10 | Serguei Spitsyn | P3 | Resolved | Fixed | b09 |
After patching 5104215 fix(that is a fix in jdk5.0u6), the attached
test program can not watch that the thread becomes BLOCKED state.
Below is the snippet related to Thread.State from JDK 5.0 API's doc.
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.State.html
-----
BLOCKED
Thread state for a thread blocked waiting for a monitor lock. A thread
in the blocked state is waiting for a monitor lock to enter a
synchronized block/method or reenter a synchronized block/method after
calling Object.wait.
WAITING
Thread state for a waiting thread. A thread is in the waiting state
due to calling one of the following methods:
Object.wait with no timeout
Thread.join with no timeout
LockSupport.park
A thread in the waiting state is waiting for another thread to perform
a particular action. For example, a thread that has called
Object.wait() on an object is waiting for another thread to call
Object.notify() or Object.notifyAll() on that object. A thread that
has called Thread.join() is waiting for a specified thread to
terminate.
-----
Test Program:
-----
public class MustBeBlocked extends Thread {
static Object _lock = new Object();
public static void main(String[] args) throws Exception {
Thread t = new MustBeBlocked();
t.start();
do {
Thread.sleep(100);
}while(t.getState()!=Thread.State.WAITING);
synchronized(_lock) {
_lock.notify();
while( t.getState()==Thread.State.WAITING) { // Must be BLOCKED
System.out.println("waiting ..");
Thread.sleep(1);
}
System.out.println( t.getState());
}
System.exit(0);
}
public void run() {
try { run0();}
catch(Exception e){e.printStackTrace();}
}
public void run0() throws Exception{
synchronized(_lock) {
_lock.wait();
}
}
}
-----
The TP's purpose is based on API's BLOCKED part "or reenter a
synchronized block/method after calling Object.wait.".
main() watches if the thread will become BLOCKED state after it is
notified from wait(). When the state becomes BLOCKED, the program
will exit.
Expected result:
(1) JDK5.0u5
# java MustBeBlocked
waiting ..
BLOCKED
Current result:
(2) JDK5.0u12(b04)
# java MustBeBlocked
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
...
(3) JDK6u2(b02)
# java MustBeBlocked
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
...
test program can not watch that the thread becomes BLOCKED state.
Below is the snippet related to Thread.State from JDK 5.0 API's doc.
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.State.html
-----
BLOCKED
Thread state for a thread blocked waiting for a monitor lock. A thread
in the blocked state is waiting for a monitor lock to enter a
synchronized block/method or reenter a synchronized block/method after
calling Object.wait.
WAITING
Thread state for a waiting thread. A thread is in the waiting state
due to calling one of the following methods:
Object.wait with no timeout
Thread.join with no timeout
LockSupport.park
A thread in the waiting state is waiting for another thread to perform
a particular action. For example, a thread that has called
Object.wait() on an object is waiting for another thread to call
Object.notify() or Object.notifyAll() on that object. A thread that
has called Thread.join() is waiting for a specified thread to
terminate.
-----
Test Program:
-----
public class MustBeBlocked extends Thread {
static Object _lock = new Object();
public static void main(String[] args) throws Exception {
Thread t = new MustBeBlocked();
t.start();
do {
Thread.sleep(100);
}while(t.getState()!=Thread.State.WAITING);
synchronized(_lock) {
_lock.notify();
while( t.getState()==Thread.State.WAITING) { // Must be BLOCKED
System.out.println("waiting ..");
Thread.sleep(1);
}
System.out.println( t.getState());
}
System.exit(0);
}
public void run() {
try { run0();}
catch(Exception e){e.printStackTrace();}
}
public void run0() throws Exception{
synchronized(_lock) {
_lock.wait();
}
}
}
-----
The TP's purpose is based on API's BLOCKED part "or reenter a
synchronized block/method after calling Object.wait.".
main() watches if the thread will become BLOCKED state after it is
notified from wait(). When the state becomes BLOCKED, the program
will exit.
Expected result:
(1) JDK5.0u5
# java MustBeBlocked
waiting ..
BLOCKED
Current result:
(2) JDK5.0u12(b04)
# java MustBeBlocked
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
...
(3) JDK6u2(b02)
# java MustBeBlocked
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
waiting ..
...
- backported by
-
JDK-2157868 REGRESSION: can not see BLOCKED state change after patching 5104215 diff.
-
- Resolved
-
-
JDK-2177057 REGRESSION: can not see BLOCKED state change after patching 5104215 diff.
-
- Closed
-
-
JDK-2153983 REGRESSION: can not see BLOCKED state change after patching 5104215 diff.
-
- Closed
-
- relates to
-
JDK-6307490 (spec thread) Thread.State or related doc should clarify valid notifyAll() behavior
-
- Closed
-
-
JDK-6611348 missed JVMTI monitor events in wait-morphing code
-
- Closed
-