1 50 package org.apache.avalon.excalibur.concurrent; 51 52 64 public class ThreadBarrier 65 { 66 private int m_threshold; 67 private int m_count; 68 69 76 public ThreadBarrier( int count ) 77 { 78 m_threshold = count; 79 m_count = 0; 80 } 81 82 89 public void barrierSynchronize() 90 throws InterruptedException  91 { 92 synchronized( this ) 93 { 94 if( m_count != m_threshold - 1 ) 95 { 96 m_count++; 97 wait(); 98 } 99 else 100 { 101 m_count = 0; 102 notifyAll(); 103 } 104 } 105 } 106 } 107 | Popular Tags |