This isn't a question specific to Apple's JVM, but this problem does
occur with Apple's (and Sun's, at least on Windows) JVM's. I'm asking
on this list because I know there are some smart folks out there and
maybe someone has experienced this before. I'm assuming this is a bug
in my code, but see #2 below, which really has me stumped. I have
seen some bug reports filed against Sun, even recent versions of
Java, which point to issues with how Java handles killing threads
when destroying applets. Also, the problem is NOT reproducible using
Microsoft's old, old, old, JVM.
Environment: Java 1.5.0_06 (OS X), Java 1.4.2_12 (Windows), and
probably others, but those are the only ones I've confirmed.
I have a fairly simple applet that does use some fairly complex,
multi-threaded code. The problem is that when the page where the
applet resides is reloaded, it sometimes hangs the entire browser.
I've tracked this down to the point of knowing that a ThreadDeath
Error is being thrown. Here is the stack trace:
java.lang.ThreadDeath
at java.lang.Thread.stop(Thread.java:716)
at java.lang.ThreadGroup.stopOrSuspend(ThreadGroup.java:671)
at java.lang.ThreadGroup.stopOrSuspend(ThreadGroup.java:681)
at java.lang.ThreadGroup.stopOrSuspend(ThreadGroup.java:681)
at java.lang.ThreadGroup.stop(ThreadGroup.java:584)
at sun.awt.AppContext.dispose(AppContext.java:420)
at sun.applet.AppletClassLoader.release(AppletClassLoader.java:711)
at sun.plugin.security.PluginClassLoader.release
(PluginClassLoader.java:438)
at sun.applet.AppletPanel.release(AppletPanel.java:175)
at sun.applet.AppletPanel.sendEvent(AppletPanel.java:273)
at sun.plugin.AppletViewer.onPrivateClose(AppletViewer.java:850)
at sun.plugin.AppletViewer$2.run(AppletViewer.java:812)
at java.lang.Thread.run(Thread.java:613)
I have a couple questions:
1. Given that Sun deprecated Thread.stop() ages ago, why are Sun
themselves calling the stop method?
2. According to the debugging I've been able to do, this ThreadDeath
error is being thrown ON A NEWLY CREATED thread AFTER the applet has
already completely reloaded and is actually running. This whole
process of shutting down the applet and then reloading it takes less
than two seconds. I'm just reloading the page. The breakdown is: The
applet is stopped via stop(), then destroyed via destroy(). My
threads are shut down. The page reloads, and the applet reloads,
running its init() and start() methods. The applet starts running and
then *boom*, maybe 20% of the time it gets a ThreadDeath error. This
makes no sense to me. The threads from the previous incarnation of
the applet HAVE been cleaned up and have gone away. So why does JVM
send this ThreadDeath Error? And why send it to my newly created
thread which was running along perfectly fine?
Catching and discarding the ThreadDeath error is not an option.
You're not supposed to do that, and besides, I tried and it doesn't
help.
Any thoughts? Thanks.
Rob
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden