46 |
|
public void testExecuteRunnable() throws Exception { |
47 |
|
ExecutorService e = new DirectExecutorService(); |
48 |
|
final AtomicBoolean done = new AtomicBoolean(false); |
49 |
< |
CheckedRunnable task = new CheckedRunnable() { |
49 |
> |
Future<?> future = e.submit(new CheckedRunnable() { |
50 |
|
public void realRun() { |
51 |
|
done.set(true); |
52 |
< |
}}; |
53 |
< |
Future<?> future = e.submit(task); |
52 |
> |
}}); |
53 |
|
assertNull(future.get()); |
54 |
|
assertNull(future.get(0, MILLISECONDS)); |
55 |
|
assertTrue(done.get()); |
212 |
|
new ArrayBlockingQueue<Runnable>(10)); |
213 |
|
|
214 |
|
Callable c = new Callable() { |
215 |
< |
public Object call() { return 5/0; }}; |
215 |
> |
public Object call() { throw new ArithmeticException(); }}; |
216 |
|
|
217 |
|
try { |
218 |
|
p.submit(c).get(); |
256 |
|
*/ |
257 |
|
public void testInvokeAny3() throws Exception { |
258 |
|
ExecutorService e = new DirectExecutorService(); |
259 |
< |
List<Callable<Integer>> l = new ArrayList<Callable<Integer>>(); |
260 |
< |
l.add(new Callable<Integer>() { |
261 |
< |
public Integer call() { return 5/0; }}); |
259 |
> |
List<Callable<Long>> l = new ArrayList<Callable<Long>>(); |
260 |
> |
l.add(new Callable<Long>() { |
261 |
> |
public Long call() { throw new ArithmeticException(); }}); |
262 |
|
l.add(null); |
263 |
|
try { |
264 |
|
e.invokeAny(l); |
434 |
|
*/ |
435 |
|
public void testTimedInvokeAny3() throws Exception { |
436 |
|
ExecutorService e = new DirectExecutorService(); |
437 |
< |
List<Callable<Integer>> l = new ArrayList<Callable<Integer>>(); |
438 |
< |
l.add(new Callable<Integer>() { |
439 |
< |
public Integer call() { return 5/0; }}); |
437 |
> |
List<Callable<Long>> l = new ArrayList<Callable<Long>>(); |
438 |
> |
l.add(new Callable<Long>() { |
439 |
> |
public Long call() { throw new ArithmeticException(); }}); |
440 |
|
l.add(null); |
441 |
|
try { |
442 |
|
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |