SHOTbyGUN

KillerDaemon.java

Aug 14th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. package com.shotbygun.shotmod.common.system;
  2.  
  3. import com.shotbygun.shotmod.common.logger.Log;
  4.  
  5. /**
  6.  *
  7.  * @author shotbygun
  8.  */
  9. public class KillerDaemon extends RunnableSystem {
  10.    
  11.     private final RunnableSystem[] systemArray;
  12.    
  13.     public KillerDaemon(RunnableSystem[] systemArray) {
  14.         this.systemArray = systemArray;
  15.     }
  16.    
  17.     @Override
  18.     public void run() {
  19.        
  20.         // This thread will be run only when shutting down
  21.        
  22.         // if all else non-daemon systems are shut down, we are not required
  23.         // so we can die with the application before we can execute
  24.        
  25.         this.thread.setDaemon(true);
  26.        
  27.         try {
  28.            
  29.             Thread.sleep(6000);
  30.            
  31.             for(RunnableSystem system : systemArray) {
  32.                 system.interrupt();
  33.             }
  34.            
  35.         } catch (Exception ex) {
  36.             Log.log("shutdown", Log.LOGLEVEL_ERROR, this.getClass().getSimpleName(), "error while executing (pun intended)", ex);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment