1 4 package com.tcclient.util; 5 6 import com.tc.util.DebugUtil; 7 8 import java.util.concurrent.CyclicBarrier ; 9 10 public class TCCyclicBarrierDebugUtil { 11 public static synchronized int acquire(CyclicBarrier barrier, int participants, boolean startDebug, boolean endDebug) throws Exception { 12 int numWaiting = barrier.getNumberWaiting(); 13 if ((numWaiting == 0) && startDebug){ 14 DebugUtil.DEBUG = true; 15 } 16 int returnValue = barrier.await(); 17 if ((numWaiting == (participants -1)) && endDebug) { 18 DebugUtil.DEBUG = false; 19 } 20 return returnValue; 21 } 22 23 public static int acquire(CyclicBarrier barrier, int participants) throws Exception { 24 return acquire(barrier, participants, false, false); 25 } 26 } 27 | Popular Tags |