// return true if the task was successfully placed on the queue, false
// if the queue has been shut down.
synchronized (this) {
if (isStopped) return false;
if (! semaphore.tryAcquire()) throw new Error("too many threads");
}
try {
return taskQueue.offer(task);
} finally {
semaphore.release();
}