📄 timerqueuetest.java
字号:
// ============================================================================//// = PACKAGE// tests.Reactor// // = FILENAME// TimerQueueTest.java//// = AUTHOR// Prashant Jain// // ============================================================================package JACE.tests.Reactor;import JACE.OS.*;import JACE.ASX.*;import JACE.Reactor.*;public class TimerQueueTest implements EventHandler{ public int handleTimeout (TimeValue tv, Object obj) { ACE.DEBUG ("handleTimeout: " + tv.toString () + " " + (String) obj); return 0; } public static void main (String args []) { ACE.enableDebugging (); TimerQueue tq = new TimerQueue (true); TimerQueueTest th1 = new TimerQueueTest (); int n = 5; ACE.enableDebugging (); try { if (args.length == 1) { n = Integer.parseInt (args[0]); } } catch (NumberFormatException e) { ACE.ERROR ("Illegal argument."); } // Set a periodic timer int id = tq.scheduleTimer (th1, "periodic", new TimeValue (2), new TimeValue (3)); int i; // Set a bunch of single timers for (i=1; i <= n; i++) { tq.scheduleTimer (th1, "A-timer-" + new Integer (i), new TimeValue (i*2)); } TimerQueueTest th2 = new TimerQueueTest (); for (i=1; i <= n; i++) { tq.scheduleTimer (th2, "B-timer-" + new Integer (i), new TimeValue (i*3)); } // Cancel all timers associated with this handler tq.cancelTimer (th2); try { Thread.sleep (30000); } catch (InterruptedException e) { } tq.cancelTimer (id); System.exit (0); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -