public synchronized void setAutoShutdownEnabled ( boolean enabled ) { try { if ( mShutdownHook == null ) { if ( enabled ) { ShutdownHook hook = new ShutdownHook ( this ) ; Runtime . getRuntime ( ) . addShutdownHook ( hook ) ; mShutdownHook = hook ; } } else { if ( ! enabled ) { Runtime . getRuntime ( ) . removeShutdownHook ( mShutdownHook ) ; mShutdownHook = null ; } } } catch ( IllegalStateException e ) { // Shutdown is in progress so make no changes. } }
Required by ShutdownCapability .