long deadline
= System.
currentTimeMillis() + timeout
; long left = timeout;
do {
wait(left);
} while (!completed
&& (left
= deadline
- System.
currentTimeMillis()) > 0);
bG9uZyBkZWFkbGluZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpICsgdGltZW91dDsKbG9uZyBsZWZ0ID0gdGltZW91dDsKZG8gewogICAgd2FpdChsZWZ0KTsKfSB3aGlsZSAoIWNvbXBsZXRlZAogICAgJiYgKGxlZnQgPSBkZWFkbGluZSAtIFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpKSA+IDApOwo=