1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
159 |
|
q.put(null); |
160 |
|
shouldThrow(); |
161 |
|
} catch (NullPointerException success) {} |
162 |
< |
} |
162 |
> |
} |
163 |
|
|
164 |
|
/** |
165 |
|
* put blocks interruptibly if no active taker |
172 |
|
}}); |
173 |
|
|
174 |
|
t.start(); |
175 |
< |
Thread.sleep(SHORT_DELAY_MS); |
175 |
> |
delay(SHORT_DELAY_MS); |
176 |
|
t.interrupt(); |
177 |
|
t.join(); |
178 |
|
} |
196 |
|
}}); |
197 |
|
|
198 |
|
t.start(); |
199 |
< |
Thread.sleep(SHORT_DELAY_MS); |
199 |
> |
delay(SHORT_DELAY_MS); |
200 |
|
assertEquals(0, q.take()); |
201 |
< |
Thread.sleep(SHORT_DELAY_MS); |
201 |
> |
delay(SHORT_DELAY_MS); |
202 |
|
t.interrupt(); |
203 |
|
t.join(); |
204 |
|
} |
253 |
|
}}); |
254 |
|
|
255 |
|
t.start(); |
256 |
< |
Thread.sleep(SHORT_DELAY_MS); |
256 |
> |
delay(SHORT_DELAY_MS); |
257 |
|
t.interrupt(); |
258 |
|
t.join(); |
259 |
|
} |
277 |
|
}}); |
278 |
|
|
279 |
|
t.start(); |
280 |
< |
Thread.sleep(SHORT_DELAY_MS); |
280 |
> |
delay(SHORT_DELAY_MS); |
281 |
|
assertEquals(0, q.take()); |
282 |
< |
Thread.sleep(SHORT_DELAY_MS); |
282 |
> |
delay(SHORT_DELAY_MS); |
283 |
|
t.interrupt(); |
284 |
|
t.join(); |
285 |
|
} |
295 |
|
}}); |
296 |
|
|
297 |
|
t.start(); |
298 |
< |
Thread.sleep(SHORT_DELAY_MS); |
298 |
> |
delay(SHORT_DELAY_MS); |
299 |
|
t.interrupt(); |
300 |
|
t.join(); |
301 |
|
} |
346 |
|
}}); |
347 |
|
|
348 |
|
threadStarted.await(); |
349 |
< |
Thread.sleep(SHORT_DELAY_MS); |
349 |
> |
delay(SHORT_DELAY_MS); |
350 |
|
t.interrupt(); |
351 |
|
awaitTermination(t, MEDIUM_DELAY_MS); |
352 |
|
} |
397 |
|
long t0 = System.nanoTime(); |
398 |
|
assertTrue(q.offer(zero, LONG_DELAY_MS, MILLISECONDS)); |
399 |
|
assertTrue(millisElapsedSince(t0) < MEDIUM_DELAY_MS); |
400 |
< |
|
400 |
> |
|
401 |
|
t.interrupt(); |
402 |
|
awaitTermination(t, MEDIUM_DELAY_MS); |
403 |
|
} |
573 |
|
|
574 |
|
executor.execute(new CheckedRunnable() { |
575 |
|
public void realRun() throws InterruptedException { |
576 |
< |
Thread.sleep(SMALL_DELAY_MS); |
576 |
> |
delay(SMALL_DELAY_MS); |
577 |
|
assertSame(one, q.take()); |
578 |
|
}}); |
579 |
|
|
595 |
|
|
596 |
|
executor.execute(new CheckedRunnable() { |
597 |
|
public void realRun() throws InterruptedException { |
598 |
< |
Thread.sleep(SHORT_DELAY_MS); |
598 |
> |
delay(SHORT_DELAY_MS); |
599 |
|
q.put(one); |
600 |
|
}}); |
601 |
|
|
665 |
|
|
666 |
|
t.start(); |
667 |
|
ArrayList l = new ArrayList(); |
668 |
< |
Thread.sleep(SHORT_DELAY_MS); |
668 |
> |
delay(SHORT_DELAY_MS); |
669 |
|
q.drainTo(l); |
670 |
|
assertTrue(l.size() <= 1); |
671 |
|
if (l.size() > 0) |
714 |
|
t1.start(); |
715 |
|
t2.start(); |
716 |
|
ArrayList l = new ArrayList(); |
717 |
< |
Thread.sleep(SHORT_DELAY_MS); |
717 |
> |
delay(SHORT_DELAY_MS); |
718 |
|
q.drainTo(l, 1); |
719 |
|
assertEquals(1, l.size()); |
720 |
|
q.drainTo(l, 1); |