1 package org.jgroups.util; 2 3 10 public final class ReentrantLatch { 11 12 boolean locked; 13 14 17 public ReentrantLatch() { 18 this(false); 19 } 20 21 26 public ReentrantLatch(boolean locked) { 27 this.locked = locked; 28 } 29 30 33 public synchronized void lock() { 34 if (!locked) { 35 locked = true; 36 } 37 } 38 39 42 public synchronized void unlock() { 43 if (locked) { 44 locked = false; 45 notifyAll(); 46 } 47 } 48 49 55 public synchronized void passThrough() throws InterruptedException { 56 while (locked) { 57 wait(); 58 } 59 } 60 } | Popular Tags |