KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > test > web > Tasks


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.test.web;
6
7 /**
8  * May 24, 2004
9  * @author: Tuan Nguyen
10  * @email: tuan08@users.sourceforge.net
11  * @version: $Id: Tasks.java,v 1.1 2004/10/11 23:36:03 tuan08 Exp $
12  **/

13 public class Tasks {
14   int numberOfTask_ ;
15   int counter_ ;
16   private ExoWebClient webClient_ ;
17   private String JavaDoc taskNamePrefix_ ;
18   
19   public Tasks(int numberOfTask, ExoWebClient webClient) {
20     numberOfTask_ = numberOfTask ;
21     webClient_ = webClient ;
22     reset() ;
23   }
24   
25   public void reset() {
26     counter_ = 0 ;
27     taskNamePrefix_ = "user-" + ((int) (Math.random() * 100000)) + "-";
28   }
29   
30   synchronized public int getUnfinishedTaskCounter() {
31     return numberOfTask_ - counter_ ;
32   }
33   
34   synchronized public Runnable JavaDoc getNextTask() {
35     if (counter_ < numberOfTask_) {
36       counter_++ ;
37       return webClient_.clone(taskNamePrefix_ + counter_ ) ;
38     }
39     return null ;
40   }
41 }
Popular Tags