-
Bug
-
Resolution: Fixed
-
P2
-
6u3
-
b10
-
x86
-
windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2171596 | 5.0u18 | Vikram Aroskar | P2 | Resolved | Fixed | b01 |
JDK-2165640 | 5.0u16-rev | Vikram Aroskar | P2 | Resolved | Fixed | b12 |
type: bug
product: j2se
sub-cat: java.util.*
release: Java 6
O/S: Windows XP
Synopsis: Scheduling large negative delay hangs entire ScheduledExecutor
Full O/S version: Microsoft Windows XP [Version 5.1.2600]
java -version:
both
java version "1.5.0_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode)
and
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)
Description:
Scheduling something with a very large negative delay (using TimeUnit.MILLISECONDS) blocks the scheduled executor from running anything. Other than perhaps relative ordering, negative delay (no matter how large) is effectively the same as zero delay and the scheduled item ought to be eligible to run immediately.
Frequency: always
Regression: no
Steps to reproduce:
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class ScheduleBug {
public static void main(String[] args) {
ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
exec.schedule(new Op("one"), -1000, TimeUnit.MILLISECONDS);
exec.schedule(new Op("two"), -100, TimeUnit.MILLISECONDS);
exec.schedule(new Op("three"), -10, TimeUnit.MILLISECONDS);
exec.schedule(new Op("four"), 0, TimeUnit.MILLISECONDS);
exec.schedule(new Op("five"), 1000, TimeUnit.MILLISECONDS);
exec.schedule(new Op("six"), 5000, TimeUnit.MILLISECONDS);
exec.schedule(new Runnable() {
public void run() { System.exit(0); }
}, 10000, TimeUnit.MILLISECONDS);
}
static class Op implements Runnable {
private final String m_message;
public Op(String message)
{ m_message = message; }
public void run() {
System.out.println(m_message);
System.out.flush();
}
}
}
produces the following output as expected (after 10-15s):
one
two
three
four
five
six
However, change the first schedule line from
exec.schedule(new Op("one"), -1000, TimeUnit.MILLISECONDS);
to
exec.schedule(new Op("one"), Long.MIN_VALUE, TimeUnit.MILLISECONDS);
and the program will hang for hours with no output at all.
problems:
1) should be exact same output.
2) Even if underflow were documented / specified behavior, scheduling op "one" far in the future should NOT prevent other ops from running right away
severity: some progress possible
product: j2se
sub-cat: java.util.*
release: Java 6
O/S: Windows XP
Synopsis: Scheduling large negative delay hangs entire ScheduledExecutor
Full O/S version: Microsoft Windows XP [Version 5.1.2600]
java -version:
both
java version "1.5.0_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode)
and
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)
Description:
Scheduling something with a very large negative delay (using TimeUnit.MILLISECONDS) blocks the scheduled executor from running anything. Other than perhaps relative ordering, negative delay (no matter how large) is effectively the same as zero delay and the scheduled item ought to be eligible to run immediately.
Frequency: always
Regression: no
Steps to reproduce:
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class ScheduleBug {
public static void main(String[] args) {
ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
exec.schedule(new Op("one"), -1000, TimeUnit.MILLISECONDS);
exec.schedule(new Op("two"), -100, TimeUnit.MILLISECONDS);
exec.schedule(new Op("three"), -10, TimeUnit.MILLISECONDS);
exec.schedule(new Op("four"), 0, TimeUnit.MILLISECONDS);
exec.schedule(new Op("five"), 1000, TimeUnit.MILLISECONDS);
exec.schedule(new Op("six"), 5000, TimeUnit.MILLISECONDS);
exec.schedule(new Runnable() {
public void run() { System.exit(0); }
}, 10000, TimeUnit.MILLISECONDS);
}
static class Op implements Runnable {
private final String m_message;
public Op(String message)
{ m_message = message; }
public void run() {
System.out.println(m_message);
System.out.flush();
}
}
}
produces the following output as expected (after 10-15s):
one
two
three
four
five
six
However, change the first schedule line from
exec.schedule(new Op("one"), -1000, TimeUnit.MILLISECONDS);
to
exec.schedule(new Op("one"), Long.MIN_VALUE, TimeUnit.MILLISECONDS);
and the program will hang for hours with no output at all.
problems:
1) should be exact same output.
2) Even if underflow were documented / specified behavior, scheduling op "one" far in the future should NOT prevent other ops from running right away
severity: some progress possible
- backported by
-
JDK-2165640 Scheduling large negative delay hangs entire ScheduledExecutor
- Resolved
-
JDK-2171596 Scheduling large negative delay hangs entire ScheduledExecutor
- Resolved
- relates to
-
JDK-6725789 ScheduledExecutorService does not work as expected in jdk7/6/5
- Closed