public boolean complete(int timeout) {
if (timeout < 0)
throw new IllegalArgumentException();
if (!completed) {
ElapsedTime startTime = new ElapsedTime();
synchronized (this) {
while (!completed) {
long waitTime = timeout - startTime.getElapsedTime();
if (waitTime <= 0)
break;
dispatcher.block(); // block dispatcher
try {
wait(waitTime);