1 5 package org.exoplatform.test.web; 6 7 13 public class Tasks { 14 int numberOfTask_ ; 15 int counter_ ; 16 private ExoWebClient webClient_ ; 17 private String 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 getNextTask() { 35 if (counter_ < numberOfTask_) { 36 counter_++ ; 37 return webClient_.clone(taskNamePrefix_ + counter_ ) ; 38 } 39 return null ; 40 } 41 } | Popular Tags |