Forum Navigation
Threads, exceptions, and aborting
Posted: 11/14/08 16:33:18I'm writing my very first multithreaded application. It's buggy. It throws exceptions.
When an exception is thrown in a thread other than the main one, the thread silently dies.
I've been running like this:
interface IThreadRunnable { void run(); } void run (IThreadRunnable runnable) { (new Thread (&runnable.run)).start; }Now I'm running it like this:
interface IThreadRunnable { void run(); } class ThreadRunner { IThreadRunnable runnable; void run () { try { runnable.run; } catch (Exception ex) { log (ex); exit (1); } } } void run (IThreadRunnable runnable) { (new Thread (&(new ThreadRunner(runnable)).run)).start; }This isn't very pretty. Is there a better way of doing this?