1 package edu.rice.cs.util; 2 3 6 public class CompletionMonitor { 7 private boolean _flag; 8 9 public CompletionMonitor(boolean flag) { _flag = flag; } 10 11 public CompletionMonitor() { this(false); } 12 13 14 public synchronized boolean isFlag() { return _flag; } 15 16 17 public synchronized void set() { 18 _flag = true; 19 this.notifyAll(); 20 } 21 22 23 public synchronized void reset() { _flag = false; } 24 25 28 public synchronized boolean waitOne() { 29 while (!_flag) { 30 try { this.wait(); } 31 catch (InterruptedException e) { return false; } 32 } 33 return true; 34 } 35 } 36 | Popular Tags |