You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by "Spasojevic, Daniel" <Sp...@AUSTRALIA.Stortek.com> on 2003/09/12 12:37:19 UTC
CleanerThread and ThreadDeath
Hi,
Batik has continued to be excellent to work with. Thanks to Thomas for
helping out with the last issue that I raised.
I am using Batik in an applet and I am seeing some strange behaviour when
the applet is stopping. I am using a version of CVS that I got today and
Java 1.4.2. I have also seen this behaviour with Batik 1.5 and Java 1.4.1.
When the Threads in the applet's ThreadGroup are being stopped, the
CleanerThread catches a ThreadDeath Error. Since this stops the propagation
of the ThreadDeath Error, the CleanerThread is never stopped. The doc for
ThreadDeath
(http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ThreadDeath.html) states
that the ThreadDeath Error should only be caught if some cleanup must be
done if it is stop asynchronously. I don't think that this is the case with
the CleanerThread.
Since I haven't seen any discussion about this on the mailing list before, I
am guessing that some peculiarity of my code is stopping the CleanerThread
from being stopped when it should, necessitating the ThreadDeath when the
applet is stopping.
Anyway, as a workaround in my code I changed the run method in
CleanerThread.java from:
public void run() {
while(true) {
try {
...
} catch (Throwable t) {
t.printStackTrace();
}
}
}
into:
public void run() {
while(true) {
try {
...
} catch (Exception e) {
e.printStackTrace();
}
}
}
This allows the ThreadDeath Error to propagate and the CleanerThread to be
forcibly shut down.
If anyone has seen a similar problem and managed to work out what it was in
their code that was causing the CleanerThread to hang around until the
applet was closed I would really appreciate hearing about it - I am not so
keen on changing the Batik code.
-Daniel Spasojevic
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: CleanerThread and ThreadDeath
Posted by Thomas DeWeese <Th...@Kodak.com>.
Spasojevic, Daniel wrote:
> Batik has continued to be excellent to work with. Thanks to Thomas for
> helping out with the last issue that I raised.
Glad to hear it.
> I am using Batik in an applet and I am seeing some strange behaviour when
> the applet is stopping. I am using a version of CVS that I got today and
> Java 1.4.2. I have also seen this behaviour with Batik 1.5 and Java 1.4.1.
>
> When the Threads in the applet's ThreadGroup are being stopped, the
> CleanerThread catches a ThreadDeath Error. Since this stops the propagation
> of the ThreadDeath Error, the CleanerThread is never stopped.
Hmm, I think it is correct that ThreadDeath not be caught the question
is if the thread should catch some of the other throwables - like
out of memory. Thanks for bringing this up.
> Since I haven't seen any discussion about this on the mailing list before, I
> am guessing that some peculiarity of my code is stopping the CleanerThread
> from being stopped when it should, necessitating the ThreadDeath when the
> applet is stopping.
This may be specific to applets most people are using Batik in applications
where I think the JVM just shuts down.
> Anyway, as a workaround in my code I changed the run method in
> CleanerThread.java from:
>
> public void run() {
> while(true) {
> try {
> ...
> } catch (Throwable t) {
> t.printStackTrace();
> }
> }
> }
>
> into:
>
> public void run() {
> while(true) {
> try {
> ...
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
>
> This allows the ThreadDeath Error to propagate and the CleanerThread to be
> forcibly shut down.
>
> If anyone has seen a similar problem and managed to work out what it was in
> their code that was causing the CleanerThread to hang around until the
> applet was closed I would really appreciate hearing about it - I am not so
> keen on changing the Batik code.
>
> -Daniel Spasojevic
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org