Forums Register Login

Centralized catch for all threads

+Pie Number of slices to send: Send
Hello,
the main ui class in my project calls a method that spawns several threads. I want to know if there is a way i can put a centralized catch so that all the exceptions are caught in this.
e.g MainUI.java
..
try{
//this method spawns several threads which may throw exceptions
ProjectManager.analyze();
}catch(Throwable t){
LogError("Exception" + t + "in some thread spasned by PM.analyze");
}

Thanks in advance,
Vivek
+Pie Number of slices to send: Send
hi folks,
the response is very discouraging.
atleast let me know if at all there is any solutionn to this problem.
expecting at least some reply.
pl help
Thanks,
Vivek
+Pie Number of slices to send: Send
Well, there's at least a way to handle uncaught exceptions if your spawned threads belong to the same ThreadGroup. Create a ThreadGroup subclass and override its uncaughtException method. When creating your threads, be sure to use the constructor that takes a ThreadGroup instance. Hope that helps.
Can't .... do .... plaid .... So I did this tiny ad instead:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 830 times.
Similar Threads
uncaught exception handling
Logging every error
Centralized catch for all threads
More than 17 clients CRASH?!
ServletContextListener (contextDestroyed) with Threads
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:10:16.