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); } }
void terminate() { isContinued = false; setReq( new Request() { @Override public void execute(String in) { // do nothing. } @Override public String getURL() { return null; } }); }