Guest User

Untitled

a guest
Dec 27th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1.     static boolean checked = true;
  2.     static Thread tz = null;
  3.    
  4.     public static void main(String[] args) throws Throwable {
  5.        
  6.         if (checked){
  7.             checked = false;
  8.             tz = Thread.currentThread();
  9.  
  10.             new Thread(){
  11.                 @Override
  12.                 public void run() {
  13.                    
  14.                     for(;;)
  15.                     {
  16.                         if (!tz.isAlive()){
  17.                             System.out.println("DEAD");
  18.                             new Thread(){
  19.                                 public void run(){
  20.                                     try
  21.                                     {
  22.                                         tz = Thread.currentThread();
  23.                                         UnsafeImpl.main(null);
  24.                                     } catch (Throwable e)
  25.                                     {
  26.                                         // TODO Auto-generated catch block
  27.                                         e.printStackTrace();
  28.                                     }
  29.                                 }
  30.                             }.start();
  31.                         }
  32.                         try
  33.                         {
  34.                             Thread.sleep(100l);
  35.                         } catch (InterruptedException e)
  36.                         {
  37.                             e.printStackTrace();
  38.                         }
  39.                     }
  40.                 }
  41.  
  42.             }.start();
  43.         }
  44.        
  45.         System.out.println(System.currentTimeMillis());
  46.        
  47.         for(;;)
  48.         {
  49.             if (new Random().nextInt(10) == 5)unsafe.throwException(new Exception("MAIN INTERRUPT"));
  50.             System.out.println(System.currentTimeMillis());
  51.             Thread.sleep(100l);
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment