01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tcclient.util;
05:
06: import com.tc.util.DebugUtil;
07:
08: import java.util.concurrent.CyclicBarrier;
09:
10: public class TCCyclicBarrierDebugUtil {
11: public static synchronized int acquire(CyclicBarrier barrier,
12: int participants, boolean startDebug, boolean endDebug)
13: throws Exception {
14: int numWaiting = barrier.getNumberWaiting();
15: if ((numWaiting == 0) && startDebug) {
16: DebugUtil.DEBUG = true;
17: }
18: int returnValue = barrier.await();
19: if ((numWaiting == (participants - 1)) && endDebug) {
20: DebugUtil.DEBUG = false;
21: }
22: return returnValue;
23: }
24:
25: public static int acquire(CyclicBarrier barrier, int participants)
26: throws Exception {
27: return acquire(barrier, participants, false, false);
28: }
29: }
|