Esempio n. 1
0
 synchronized void cleanIdel() {
   for (WorkerThread workerThread : workerThreads) {
     if (workerThread.isIdle()) {
       workerThreads.remove(workerThread);
       workerThread.terminate();
     }
   }
 }
Esempio n. 2
0
 private WorkerThread createWorkerThread() {
   WorkerThread wThread = new WorkerThread();
   wThread.start();
   workerThreads.add(wThread);
   try {
     Thread.sleep(100);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   return wThread;
 }
Esempio n. 3
0
 synchronized void service(Request request) {
   boolean idleNotFound = true;
   for (WorkerThread workerThread : workerThreads) {
     if (workerThread.isIdle()) {
       workerThread.setReq(request);
       idleNotFound = false;
       break;
     }
   }
   if (idleNotFound) {
     WorkerThread workerThread = createWorkerThread();
     workerThread.setReq(request);
   }
 }