I have a simple applet on a web page like this. (This is a test case cut down from a more complicated applet).
package test;
import java.applet.Applet;
@SuppressWarnings("serial")
public class SimpleLoopApplet extends Applet
{
public void init()
{
System.out.println("SimpleLoopApplet invoked");
try
{
while (true)
{
try
{
System.out.println("Sleep for 1 second");
Thread.sleep(1000);
}
catch (InterruptedException e)
{
System.out.println("Applet thread interrupted while sleeping");
}
}
}
finally {}
}
}
On Firefox 3.6.8 on one computer this applet will run for 20 seconds and then exit abruptly, as if the VM is terminating (The java console will disappear; the Java icon will remain in the system tray until I mouse over it; the finally block is never reached).
It's consistently 20 seconds. 20 "Sleep for 1 second"s printed from the above code, if I extend the sleep to 5 seconds, then 4 messages are printed before termination.
In IE and Chrome on the same computer, the loop will continue on indefinitely, as it will in Firefox 3.6.8 on a different computer.
Can anyone suggest why the applet might terminate in this way?