private static void commitSuicide ( String msg ) { Thread t = new Thread ( ( ) -> { // halt the JVM immediately unless the security manager prevents this try { System . exit ( - 1 ) ; } catch ( SecurityException ex ) { LOGGER . info ( "SecurityException prevented system exit" , ex ) ; } // log an error stating that the JVM should be manually aborted try { while ( true ) { Thread . sleep ( 5000L ) ; LOGGER . error ( "VM is in an unreliable state - please abort it!" ) ; } } catch ( InterruptedException e ) { LOGGER . info ( "JVM Instability logger terminated by interrupt" ) ; } } ) ; t . setDaemon ( true ) ; // spawn a thread here to avoid provoking deadlocks t . start ( ) ; throw new Error ( msg ) ; }
Try to terminate the VM as soon as possible no matter the method and how abrupt it may be .