KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > performance > http > load > RequestCounter


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.tctest.performance.http.load;
5
6 class RequestCounter {
7   
8   private int count;
9   private static final long TIMEOUT = 60 * 1000;
10
11   public synchronized void increment() {
12     count++;
13     notify();
14   }
15
16   public synchronized void waitForCount(int target) throws InterruptedException JavaDoc {
17     long time = System.currentTimeMillis() + TIMEOUT;
18     while (count < target && System.currentTimeMillis() < time) wait();
19     if (System.currentTimeMillis() >= time) System.out.println("Request Timeout");
20     count = 0;
21   }
22 }
23
Popular Tags