I am working on a J2ME project that creates workflows to perform numerous tasks, such as loading HTTP content. The basic layout of threads is similar to most java applications - there is a main user interface thread and workflows created to work behind the scenes. My question is the best way to handle exceptions thrown in workflows?
I usually adhere to the rationale that most exceptions should be percolated as much as possible. When I write single-threaded applications, it is common for me to overflow exceptions up to the user interface level, and then report them to the user in the error dialog box. Is there a similar practice for multithreaded applications? The most intuitive thing for me is to catch the exceptions in Thread.run () and then call invokeLater in the user interface thread to report this in the dialog box. The problem I see here is that outside of the workflow that prematurely dies, this approach does not really notify the user interface thread, an error has occurred. I donโt see a clear way to throw an exception on threads, so to speak.
Thanks Andy
source share