multithreading - Tracking a disappearing thread in Java -


i've got thread dies on me.

the thread main loop like:

    while (true) {         try {             <snip>         } catch (interruptedexception e) {             e.printstacktrace();         } catch (throwable e) {             e.printstacktrace();         }     } 

and start like:

    thread.setuncaughtexceptionhandler((thread, throwable) -> {         throwable.printstacktrace();     }); 

i have repeatable situation in program stops working , when invoke eclipse debugger thread seen.

how can happen , how can trace it, have thought code catch possible ways thread exit , stack trace of going on….

try wrapping code, @ highest level, try/finally block. should catch when code exits block unless system.exit() called.

as discovered, 1 way code might drop out silently if used return; without realising it.


you uncaught exception handler handle uncaught exceptions. in case appear catching exceptions.

the method called when have uncaught exception in thread.

/**  * dispatch uncaught exception handler. method  * intended called jvm.  */ private void dispatchuncaughtexception(throwable e) {     getuncaughtexceptionhandler().uncaughtexception(this, e); } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -