1 17 package org.columba.core.base; 18 19 public class Barrier { 20 21 boolean open; 22 23 public Barrier() { 24 this.open = false; 25 } 26 27 public synchronized void join() { 28 while (!this.open) { 29 try { 30 wait(); 31 } catch (InterruptedException e) { 32 e.printStackTrace(); 33 } 34 } 35 36 notifyAll(); 38 } 39 40 public synchronized void open() { 41 this.open = true; 42 notifyAll(); 43 } 44 45 public void close() { 46 this.open = false; 47 } 48 49 } 50 | Popular Tags |