1 package org.tanukisoftware.wrapper.test; 2 3 45 46 import org.tanukisoftware.wrapper.WrapperManager; 47 import org.tanukisoftware.wrapper.WrapperListener; 48 49 54 public class Restarter implements WrapperListener { 55 58 private Restarter() { 59 } 60 61 64 public Integer start(String [] args) { 65 System.out.println("start()"); 66 67 Thread restarter = new Thread ("restarter") { 69 public void run() { 70 try { 71 Thread.sleep(5000); 72 } catch (InterruptedException e) {} 73 74 Thread outputter = new Thread ("outputter") { 76 public void run() { 77 int counter = 0; 78 while(true) { 79 84 Thread.yield(); 85 86 System.out.println(" outputer line #" + (++counter)); 87 System.out.println(" 1) A long line of test data to cause lots of data to be sent to the console."); 88 System.out.println(" 2) A long line of test data to cause lots of data to be sent to the console."); 89 System.out.println(" 3) A long line of test data to cause lots of data to be sent to the console."); 90 System.out.println(" 4) A long line of test data to cause lots of data to be sent to the console."); 91 System.out.println(" 5) A long line of test data to cause lots of data to be sent to the console."); 92 System.out.println(" 6) A long line of test data to cause lots of data to be sent to the console."); 93 System.out.println(" 7) A long line of test data to cause lots of data to be sent to the console."); 94 System.out.println(" 8) A long line of test data to cause lots of data to be sent to the console."); 95 System.out.println(" 9) A long line of test data to cause lots of data to be sent to the console."); 96 System.out.println(" 10)A long line of test data to cause lots of data to be sent to the console."); 97 System.out.flush(); 98 } 99 } 100 }; 101 103 System.out.println("Requesting restart..."); 104 WrapperManager.restart(); 105 } 106 }; 107 restarter.start(); 108 109 return null; 110 } 111 112 public int stop(int exitCode) { 113 System.out.println("stop(" + exitCode + ")"); 114 115 return exitCode; 116 } 117 118 public void controlEvent(int event) { 119 System.out.println("controlEvent(" + event + ")"); 120 if (event == WrapperManager.WRAPPER_CTRL_C_EVENT) { 121 WrapperManager.stop(0); 122 } 123 } 124 125 128 public static void main(String [] args) { 129 System.out.println("Initializing..."); 130 131 WrapperManager.start(new Restarter(), args); 136 } 137 } 138 139 | Popular Tags |