1 package org.jacorb.trading.util; 2 11 12 public class TimerListNode{ 13 private TimerListNode next = null; 14 private boolean do_interrupt = true; 15 private boolean interrupt_sent = false; 16 17 public Thread interruptee = null; 18 public long wakeup_time; 19 20 public TimerListNode(){} 21 22 public TimerListNode(Thread interruptee, long wakeup_time){ 23 this.interruptee = interruptee; 24 this.wakeup_time = wakeup_time; 25 } 26 27 public boolean hasNext(){ 28 return next != null; 29 } 30 31 37 public synchronized TimerListNode getNext(){ 38 while (next == null) 39 try{ 40 wait(); 41 }catch(Exception _e){ 42 } 43 44 return next; 45 } 46 47 53 public synchronized void setNext(TimerListNode node){ 54 next = node; 55 notifyAll(); 56 } 57 58 59 public synchronized void doInterrupt(){ 60 if (do_interrupt){ 61 interrupt_sent = true; 62 interruptee.interrupt(); 63 } 64 } 65 66 public synchronized void stopTimer(){ 67 68 if (! interrupt_sent) 69 do_interrupt = false; 70 else 71 try{ 72 wait(); }catch(Exception _e){ 74 } 75 } 76 } 78 79 80 81 82 83 84 85 86 87 88 89 | Popular Tags |