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