Exemplo n.º 1
0
 synchronized void cleanIdel() {
   for (WorkerThread workerThread : workerThreads) {
     if (workerThread.isIdle()) {
       workerThreads.remove(workerThread);
       workerThread.terminate();
     }
   }
 }
Exemplo 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;
 }
Exemplo 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);
   }
 }