Topic
  • No replies
SystemAdmin
SystemAdmin
235 Posts

Pinned topic Behavior of a thread interrupting itself

‏2008-07-24T21:24:26Z |
I have noticed a difference in behavior between 1.4.2 SR7 and 1.4.2 SR10 which I cannot fully explain. The code below is a simplification of similar code which runs in a tomcat server environment. In the real world case, this causes a crash (core dump) on SR10, but proceeds 'normally' on SR7 (as well as on Sun JVM 1.4.2_13). The code itself does seem cyclical and probably is the actual cause of the issue...I am more curious as to why it would behave differently or how I might find out more.
public class InterruptSelf {
public static void main(String[] args) throws Exception {
Thread t = new Thread() {
public void run(){
System.out.println("before irq");
this.interrupt();
System.out.println("after irq");
}
};
t.start();
Thread.sleep(10000);
}
}

With SR7:
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2)
Classic VM (build 1.4.2, J2RE 1.4.2 IBM AIX build ca142-20061124 (SR7) (JIT enabled: jitc))

The output is:
before irq
after irq
<10 seconds of waiting, then apparent normal exit>

With SR10:
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2)
Classic VM (build 1.4.2, J2RE 1.4.2 IBM AIX build ca142-20080122 (SR10) (JIT enabled: jitc))

The output is:
before irq
<10 seconds of waiting, then apparent normal exit>

The after irq never appears.
Again, this is just bizarre code, but it has me puzzled.

Thanks.