-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
8u5
-
x86_64
-
linux
FULL PRODUCT VERSION :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux 3.14.20-20.44.amzn1.x86_64 #1 SMP Mon Oct 6 22:52:46 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Also reproduces on Windows 8.
A DESCRIPTION OF THE PROBLEM :
High cpu load when using multiple threads with
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(demiThread, 0, 250, TimeUnit.MILLISECONDS);
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
low cpu usage
ACTUAL -
high cpu usage considering workaround
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
for (int i=0;i<20;i++) {
Runnable demiThread = new Runnable() {
@Override
public void run() {
//do stuff
int sum =0;
for (int j=0;j<10_000_000;j++) {
sum+=j;
}
}
};
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(demiThread, 0, 250, TimeUnit.MILLISECONDS);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
public static void main(String[] args) {
for (int i=0;i<20;i++) {
Runnable demiThread = new Runnable() {
@Override
public void run() {
//do stuff
while (true) {
int sum =0;
for (int j=0;j<10_000_000;j++) {
sum+=j;
}
try {
Thread.sleep(250);
}
catch (Exception ignored) {}
}
}
};
Executors.newSingleThreadExecutor().submit(demiThread);
}
}
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux 3.14.20-20.44.amzn1.x86_64 #1 SMP Mon Oct 6 22:52:46 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Also reproduces on Windows 8.
A DESCRIPTION OF THE PROBLEM :
High cpu load when using multiple threads with
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(demiThread, 0, 250, TimeUnit.MILLISECONDS);
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
low cpu usage
ACTUAL -
high cpu usage considering workaround
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
for (int i=0;i<20;i++) {
Runnable demiThread = new Runnable() {
@Override
public void run() {
//do stuff
int sum =0;
for (int j=0;j<10_000_000;j++) {
sum+=j;
}
}
};
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(demiThread, 0, 250, TimeUnit.MILLISECONDS);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
public static void main(String[] args) {
for (int i=0;i<20;i++) {
Runnable demiThread = new Runnable() {
@Override
public void run() {
//do stuff
while (true) {
int sum =0;
for (int j=0;j<10_000_000;j++) {
sum+=j;
}
try {
Thread.sleep(250);
}
catch (Exception ignored) {}
}
}
};
Executors.newSingleThreadExecutor().submit(demiThread);
}
}