/** * Remove the service thread from the pool. */ protected void remove() { terminated = true; boolean notify = false; synchronized(ThreadPool.this) { // System.out.println("readded: "+this); pool.remove(this); parked.remove(this); // System.out.println("thread terminating: "+this+" "+pool.size()+" "+parked.size()); if(!finished && pool.size()==0 && parked.size()==0) { finished = true; notify = true; // System.out.println("pool terminated: "+ThreadPool.this); } } if(notify) notifyFinishListeners(); }