Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED, buy why?] Re: Why does applet sometimes receive a ThreadDeath Error?



Thanks to Moises and Greg for their replies.

I have solved the problem, but I don't understand why my solution solved the problem.

There actually were several threads that were not being explicitly shut down. The reason I didn't look at these as the source of the problem is that several of them had been around for quite some time in this code and had never caused problems. Also, none of them are directly involved with the particular thread which was receiving this ThreadDeath Error.

These "extra" threads are pretty simple. All but one of them simply monitor some local caches, waiting to clear their particular cache at some specified time.

The other thread is the one that was causing problems. This one had also been around in one form or another for a long time as well, and it wasn't causing any problems. It used to be a private inner class, but is now its own class (significant? I can't imagine why.). Also, it would only get started once (it was a static) and would die when the applet was reloaded. This was undesirable so I changed the code so that this thread would get re-created if it had died. This change appears to be significant. But there is a second significant fact: It makes a (quick) network connection to the server (only about once per minute). But it had always done this, even when it hadn't been causing problem. If I remove that network access, it no longer causes problems, even with the thread being re-created as needed. Go figure.

To summarize:

1. A statically held thread. I didn't actually test this as a necessary condition. I'm assuming it's necessary given the JVM's weird behavior with applets and static references.
2. Gets re-created when it dies.
3. Performs network access at least once before dying and being re- created.
4. Sun's plugin.


If (1 && 2 && 3 && 4) { Browser will freeze on applet shutdown; }

Btw, to answer Greg's specific questions. The two browsers I tested were Safari and IE (on Windows). The problem only manifests with Apple's or Sun's JVM. The Microsoft JVM did not have this problem. So, as you alluded to, I would suspect the plugin as the "cause" of the problem. Although it may be that the plugin is behaving more correctly and is exposing some bug in my code. But I'm still unclear exactly what that bug is.

Rob

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Why does applet sometimes receive a ThreadDeath Error? (From: Greg Guerin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.