Fran said:
I´ve developped an applet that run Threads and I wanna handle the
errors throwing exceptions. I´ve readen a lot of post and they comment
that is impossible make it. But I´ve not found a good solution. Can
anybody help me?
Much depends on what you mean to do with such exceptions. One
alternative is to create a subclass of ThreadGroup that overrides the
uncaughtException() method (compatibly!) so that it does something
useful to you. You then assign the threads created by your applet to an
instance of this ThreadGroup. Do note that the uncaughtException method
will be invoked by some unspecified thread in the JVM, which is probably
not the thread wherein the exception was thrown, and surely not the
applet's main thread (inasmuch as it has one). All that assumes you
mean to do something different than handle exceptions by making
appropriate use of Java's try / catch mechanism within the context of a
single thread.
If any of that fails to make sense to you, then you would be best off to
study some of the basics of programming with threads, and possibly the
basics of using exceptions. Writing correct multithreaded programs is
tricky -- easier in Java than in some languages, but tricky anywhere.
If you don't have a firm grasp of the language basics before you start
in to work with threads then you are toast. Crispy brown toast.
John Bollinger
(e-mail address removed)