-
Bug
-
Resolution: Duplicate
-
P3
-
8, 9, 10
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [版本 10.0.10586]
EXTRA RELEVANT SYSTEM CONFIGURATION :
notebook computer
ASUS A550JK
CPU:Intel(R) Core(TM) i7-4710HQ @2.50GHz
A DESCRIPTION OF THE PROBLEM :
If there are some threads(less than the number of computer's logic cpus) working with a endless loop(in that loop:increases an int variable(eg: ++i) and makes a comparison with '==',and has a volatile write), the function 'Thread.sleep' in other thread won't work correctly.
REGRESSION. Last worked in version 8u77
ADDITIONAL REGRESSION INFORMATION:
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just execute the test
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The console will print the sleep time per half-second:
sleep time:0 vInt:0
sleep time:501 vInt:20982098
sleep time:500 vInt:41807469
sleep time:500 vInt:65160899
sleep time:501 vInt:90615990
sleep time:500 vInt:115868104
sleep time:501 vInt:134387463
sleep time:500 vInt:157016031
sleep time:500 vInt:177084187
ACTUAL -
It takes a long time(it's 96 seconds in this test) to print the third printout, means that it slept 96 seconds rather than 0.5 second
sleep time:0 vInt:0
sleep time:501 vInt:19474440
sleep time:96389 vInt:103
sleep time:500 vInt:23039342
sleep time:500 vInt:43348896
sleep time:501 vInt:64601276
sleep time:500 vInt:90043833
sleep time:500 vInt:108501281
sleep time:501 vInt:131417790
sleep time:500 vInt:153950317
And the running jvisualvm.exe will frozen once this test start.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class SleepTest {
private static volatile int vInt = 0;
public static void main(String[] args){
for(int n=0;n<2;n++){
new Thread(){
public void run() {
int l=0,m=0;
while(true){
if(++l==0){
if(++m == 0)
//insure that it won't be optimized away
System.out.println(l);
}
vInt=l;
}
}
}.start();
}
long oldTime = System.currentTimeMillis();
while(true){
System.out.println("sleep time:"+(-oldTime+(oldTime = System.currentTimeMillis()))+"\t\tvInt:"+vInt);
try {
Thread.sleep(500);
} catch (InterruptedException e) {}
}
}
}
---------- END SOURCE ----------
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [版本 10.0.10586]
EXTRA RELEVANT SYSTEM CONFIGURATION :
notebook computer
ASUS A550JK
CPU:Intel(R) Core(TM) i7-4710HQ @2.50GHz
A DESCRIPTION OF THE PROBLEM :
If there are some threads(less than the number of computer's logic cpus) working with a endless loop(in that loop:increases an int variable(eg: ++i) and makes a comparison with '==',and has a volatile write), the function 'Thread.sleep' in other thread won't work correctly.
REGRESSION. Last worked in version 8u77
ADDITIONAL REGRESSION INFORMATION:
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just execute the test
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The console will print the sleep time per half-second:
sleep time:0 vInt:0
sleep time:501 vInt:20982098
sleep time:500 vInt:41807469
sleep time:500 vInt:65160899
sleep time:501 vInt:90615990
sleep time:500 vInt:115868104
sleep time:501 vInt:134387463
sleep time:500 vInt:157016031
sleep time:500 vInt:177084187
ACTUAL -
It takes a long time(it's 96 seconds in this test) to print the third printout, means that it slept 96 seconds rather than 0.5 second
sleep time:0 vInt:0
sleep time:501 vInt:19474440
sleep time:96389 vInt:103
sleep time:500 vInt:23039342
sleep time:500 vInt:43348896
sleep time:501 vInt:64601276
sleep time:500 vInt:90043833
sleep time:500 vInt:108501281
sleep time:501 vInt:131417790
sleep time:500 vInt:153950317
And the running jvisualvm.exe will frozen once this test start.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class SleepTest {
private static volatile int vInt = 0;
public static void main(String[] args){
for(int n=0;n<2;n++){
new Thread(){
public void run() {
int l=0,m=0;
while(true){
if(++l==0){
if(++m == 0)
//insure that it won't be optimized away
System.out.println(l);
}
vInt=l;
}
}
}.start();
}
long oldTime = System.currentTimeMillis();
while(true){
System.out.println("sleep time:"+(-oldTime+(oldTime = System.currentTimeMillis()))+"\t\tvInt:"+vInt);
try {
Thread.sleep(500);
} catch (InterruptedException e) {}
}
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8186027 C2: loop strip mining
- Resolved
- relates to
-
JDK-8192908 -XX:+UseCountedLoopSafepoints alone doesn't disable strip mining with G1
- Resolved
-
JDK-8279622 C2: miscompilation of map pattern as a vector reduction
- Resolved
-
JDK-8192977 LoopStripMiningIter is set to 1000 if UseCountedLoopSafepoints is enabled
- Closed