1 7 8 package test.compliance.monitor.support; 9 10 import test.compliance.monitor.MonitorSUITE; 11 12 public class MonitorSupport 13 { 14 boolean done = false; 15 String last = "set"; 16 public synchronized void lock(String who) 17 { 18 if (!done && last.equals(who)) 19 { 20 try 21 { 22 wait(MonitorSUITE.MAX_WAIT); 23 } 24 catch (InterruptedException e) {} 25 if (!done && last.equals(who)) 26 throw new RuntimeException("-- Time Out --"); 27 } 28 } 29 public synchronized void unlock(String who) 30 { 31 if (!done && last.equals(who)) 32 throw new RuntimeException("-- Synchronization failure --"); 33 last=who; 34 notifyAll(); 35 } 36 public synchronized void end() 37 { 38 done = true; 39 notifyAll(); 40 } 41 } 42 | Popular Tags |