public static void silenceUncaughtExceptionsInThisThread ( ) { Thread . currentThread ( ) . setUncaughtExceptionHandler ( new Thread . UncaughtExceptionHandler ( ) { @ Override public void uncaughtException ( Thread ignored , Throwable ignored1 ) { } } ) ; }
The default uncaught exception handler will print to STDERR which we don t always want for threads . Using this utility method you can avoid writing to STDERR on a per - thread basis