376 |
|
WaitNode q = null; |
377 |
|
boolean queued = false; |
378 |
|
for (;;) { |
379 |
– |
if (Thread.interrupted()) { |
380 |
– |
removeWaiter(q); |
381 |
– |
throw new InterruptedException(); |
382 |
– |
} |
383 |
– |
|
379 |
|
int s = state; |
380 |
|
if (s > COMPLETING) { |
381 |
|
if (q != null) |
382 |
|
q.thread = null; |
383 |
|
return s; |
384 |
|
} |
385 |
< |
else if (s == COMPLETING) // cannot time out yet |
385 |
> |
else if (s == COMPLETING) |
386 |
> |
// We may have already promised (via isDone) that we are done |
387 |
> |
// so never return empty-handed or throw InterruptedException |
388 |
|
Thread.yield(); |
389 |
+ |
else if (Thread.interrupted()) { |
390 |
+ |
removeWaiter(q); |
391 |
+ |
throw new InterruptedException(); |
392 |
+ |
} |
393 |
|
else if (q == null) { |
394 |
|
if (timed && nanos <= 0L) |
395 |
|
return s; |