((ThreadPoolImpl)workerThreadPool).notifyForAvailableWork(this);
}
synchronized Work requestWork(long waitTime) throws TimeoutException, InterruptedException
{
Work workItem;
((ThreadPoolImpl)workerThreadPool).incrementNumberOfAvailableThreads();
if (theWorkQueue.size() != 0) {
workItem = (Work)theWorkQueue.removeFirst();
totalTimeInQueue += System.currentTimeMillis() - workItem.getEnqueueTime();
workItemsDequeued++;
((ThreadPoolImpl)workerThreadPool).decrementNumberOfAvailableThreads();
return workItem;
}
try {
long remainingWaitTime = waitTime;
long finishTime = System.currentTimeMillis() + waitTime;
do {
this.wait(remainingWaitTime);
if (theWorkQueue.size() != 0) {
workItem = (Work)theWorkQueue.removeFirst();
totalTimeInQueue += System.currentTimeMillis() - workItem.getEnqueueTime();
workItemsDequeued++;
((ThreadPoolImpl)workerThreadPool).decrementNumberOfAvailableThreads();
return workItem;
}