KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tcclient > util > TCCyclicBarrierDebugUtil


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tcclient.util;
5
6 import com.tc.util.DebugUtil;
7
8 import java.util.concurrent.CyclicBarrier JavaDoc;
9
10 public class TCCyclicBarrierDebugUtil {
11   public static synchronized int acquire(CyclicBarrier JavaDoc barrier, int participants, boolean startDebug, boolean endDebug) throws Exception JavaDoc {
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 JavaDoc barrier, int participants) throws Exception JavaDoc {
24     return acquire(barrier, participants, false, false);
25   }
26 }
27
Popular Tags