|
Quick Lists
|
|
Bug ID:
|
6725789
|
|
Votes
|
0
|
|
Synopsis
|
ScheduledExecutorService does not work as expected in jdk7/6/5
|
|
Category
|
java:classes_util_concurrent
|
|
Reported Against
|
b30
|
|
Release Fixed
|
7(b34)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
2-High
|
|
Related Bugs
|
6639183
|
|
Submit Date
|
15-JUL-2008
|
|
Description
|
ScheduledExecutorService does not work as we expect.
The test programs schedules the execution of MyTask().
--
When Mytask() is scheduled in scheduleWithFixedDelay() as follows,
-initialDelay is 0 : Execute right now
-delay is 1000[msec] : Execute every 1000[msec]
the MyTask() sometimes is not executed.
Initial execution of MyTask() is not executed and scheduled MyTask() is not executed also.
CONFIGURATION:
OS : WindowsXP(SP2,Japanese)
JRE/JDK : jdk7b30/jdk6u7/jdk5u16
Note:
The reporter says, this occus in RHEL(x86) and submitter confirms this problem occurs in Solaris10.
FREQUENCY:
The problem can be reproducible so often.
The test program sometimes finishes correctly.
EXPECTED:
The followings message will shows up.
ACTUAL:
No message. The execution seems hang.
Posted Date : 2008-07-15 08:22:44.0
|
|
Work Around
|
Avoid using delays far in the future.
|
|
Evaluation
|
As the submitter had determined the various "schedule" methods contain code of the form:
long triggerTime = now() + delay;
and if the delay is sufficiently large then overflow will occur.
When overflow occurs a negative delay-time can be stored into the delay-queue and this causes the delay queue to operate incorrectly. If you place a correct entry in the queue and then add a negative entry, while the correct entry is still there, then the correct entry is pushed down and no task ever becomes scheduled to run - and we have the hang as reported.
However, if the correct task is removed from the queue by a worker thread, prior to the negative task being submitted, then the task is correctly replaced in the queue and the test passes.
It was curious to find that:
java Test
passes, while
java -showversion Test
always hangs.
Posted Date : 2008-07-17 07:10:30.0
There is actually a more subtle underlying issue with the data structure that hides a number of potential bugs. Martin Buchholz has prepared a complete fix for delivery in to OpenJDK.
Posted Date : 2008-07-28 04:46:26.0
http://hg.openjdk.java.net/jdk7/tl/jdk/rev/f33c3846cecb
Posted Date : 2008-08-01 10:18:53.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |