-
Bug
-
Resolution: Won't Fix
-
P5
-
None
-
1.2.0
-
x86
-
windows_nt
The following program never terminates when running it with
the JIT on. It works fine if I run it with -Djava.compiler=symcjit.
It runs fine with the HotSpot VM too.
---- session ----
D:\renes\opto\testing>java -classic -Djava.compiler=NONE Loop2
Main started
Count 0
loop started
Count -218303
Send kill signal
Thread is dead
java.lang.ThreadDeath
loop ended
D:\renes\opto\testing>java -classic Loop2
Main started
loop started
Count 0
Count -5036218
Send kill signal
Thread is dead
^C <==== HANGS
D:\renes\opto\testing>java -classic -version
java version "1.2"
Classic VM (build JDK-1.2-V, native threads)
----- Loop2.java ------
class Counter implements Runnable {
int _count = 0;
public void run() {
loop(false);
}
boolean _once;
void loop(boolean once) {
System.out.println("loop started");
try {
for(int j = 1; j < 32767 * 32767; j++) {
for(int i = 1; i < 32767 * 32767; i++) {
_count += _count + i * j;
}
}
} catch(Throwable e) {
System.out.println(e);
} finally {
System.out.println("loop ended");
}
}
int getCount() { return _count; }
}
public class Loop2 {
public static void main(String[] args) {
System.out.println("Main started");
Counter c = new Counter();
Thread t = new Thread(c);
t.start();
for(int i = 0; i < 2; i++) {
System.out.println("Count " + c.getCount());
System.gc();
pause();
}
System.out.println("Send kill signal");
t.stop();
while(t.isAlive()) {
pause();
}
System.out.println("Thread is dead");
}
static void pause() {
try {
Thread.sleep(50);
} catch(InterruptedException e) {}
}
}