-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b48
-
sparc
-
solaris_9
FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
SunOS mary 5.9 Generic_117171-07 sun4u sparc SUNW,Sun-Blade-100
A DESCRIPTION OF THE PROBLEM :
java.lang.management.ThreadInfo.getWaitedTime and java.lang.management.ThreadInfo.getWaitedCount do not take Thread.sleep in account, which contradicts the specification of these methods. For instance:
getWaitedCount:
"Returns the total number of times that the thread associated with this ThreadInfo ... has been in the WAITING or TIMED_WAITING state."
TIMED_WAITING: "Thread state for a waiting thread with a specified waiting time. A thread is in the timed waiting state due to calling one of the following methods with a specified positive waiting time: Thread.sleep ..."
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the program below
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2000-0=2000 (or any number near 2000)
2-0=2
ACTUAL -
1011-0=1011
1-0=1
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Sleep {
public synchronized static void main(String[] args) throws InterruptedException {
java.lang.management.ThreadMXBean thrbean =
java.lang.management.ManagementFactory.getThreadMXBean();
if (!thrbean.isThreadContentionMonitoringSupported()) {
throw new Error();
}
thrbean.setThreadContentionMonitoringEnabled(true);
long currThreadId = Thread.currentThread().getId();
long cstart = thrbean.getThreadInfo(currThreadId).getWaitedCount();
long start = thrbean.getThreadInfo(currThreadId).getWaitedTime();
Thread.sleep(1000);
Sleep.class.wait(1000);
long end = thrbean.getThreadInfo(currThreadId).getWaitedTime();
long cend = thrbean.getThreadInfo(currThreadId).getWaitedCount();
System.out.println(end + "-" + start + "=" + (end-start));
System.out.println(cend + "-" + cstart + "=" + (cend-cstart));
}
}
---------- END SOURCE ----------
###@###.### 2005-07-18 10:27:42 GMT
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
SunOS mary 5.9 Generic_117171-07 sun4u sparc SUNW,Sun-Blade-100
A DESCRIPTION OF THE PROBLEM :
java.lang.management.ThreadInfo.getWaitedTime and java.lang.management.ThreadInfo.getWaitedCount do not take Thread.sleep in account, which contradicts the specification of these methods. For instance:
getWaitedCount:
"Returns the total number of times that the thread associated with this ThreadInfo ... has been in the WAITING or TIMED_WAITING state."
TIMED_WAITING: "Thread state for a waiting thread with a specified waiting time. A thread is in the timed waiting state due to calling one of the following methods with a specified positive waiting time: Thread.sleep ..."
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the program below
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2000-0=2000 (or any number near 2000)
2-0=2
ACTUAL -
1011-0=1011
1-0=1
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Sleep {
public synchronized static void main(String[] args) throws InterruptedException {
java.lang.management.ThreadMXBean thrbean =
java.lang.management.ManagementFactory.getThreadMXBean();
if (!thrbean.isThreadContentionMonitoringSupported()) {
throw new Error();
}
thrbean.setThreadContentionMonitoringEnabled(true);
long currThreadId = Thread.currentThread().getId();
long cstart = thrbean.getThreadInfo(currThreadId).getWaitedCount();
long start = thrbean.getThreadInfo(currThreadId).getWaitedTime();
Thread.sleep(1000);
Sleep.class.wait(1000);
long end = thrbean.getThreadInfo(currThreadId).getWaitedTime();
long cend = thrbean.getThreadInfo(currThreadId).getWaitedCount();
System.out.println(end + "-" + start + "=" + (end-start));
System.out.println(cend + "-" + cstart + "=" + (cend-cstart));
}
}
---------- END SOURCE ----------
###@###.### 2005-07-18 10:27:42 GMT