@ Override public void shutdown ( ) { log . info ( "Shutting down Ontology crawlers." ) ; this . executor . shutdown ( ) ; // Disable new tasks from being submitted try { // Wait a while for existing tasks to terminate if ( ! this . executor . awaitTermination ( 5 , TimeUnit . SECONDS ) ) { this . executor . shutdownNow ( ) ; // Cancel currently executing tasks // Wait a while for tasks to respond to being cancelled if ( ! this . executor . awaitTermination ( 2 , TimeUnit . SECONDS ) ) log . error ( "Pool did not terminate" ) ; } } catch ( InterruptedException ie ) { // (Re-)Cancel if current thread also interrupted this . executor . shutdownNow ( ) ; // Preserve interrupt status Thread . currentThread ( ) . interrupt ( ) ; } }
This method will be called when the server is being shutdown . Ensure a clean shutdown .