97 |
|
* @return the newly created single-threaded Executor |
98 |
|
*/ |
99 |
|
public static ExecutorService newSingleThreadExecutor() { |
100 |
< |
return new DelegatedExecutorService |
100 |
> |
return new FinalizableDelegatedExecutorService |
101 |
|
(new ThreadPoolExecutor(1, 1, |
102 |
|
0L, TimeUnit.MILLISECONDS, |
103 |
|
new LinkedBlockingQueue<Runnable>())); |
117 |
|
* @return the newly created single-threaded Executor |
118 |
|
*/ |
119 |
|
public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory) { |
120 |
< |
return new DelegatedExecutorService |
120 |
> |
return new FinalizableDelegatedExecutorService |
121 |
|
(new ThreadPoolExecutor(1, 1, |
122 |
|
0L, TimeUnit.MILLISECONDS, |
123 |
|
new LinkedBlockingQueue<Runnable>(), |
613 |
|
throws InterruptedException, ExecutionException, TimeoutException { |
614 |
|
return e.invokeAny(tasks, timeout, unit); |
615 |
|
} |
616 |
+ |
} |
617 |
+ |
|
618 |
+ |
static class FinalizableDelegatedExecutorService |
619 |
+ |
extends DelegatedExecutorService { |
620 |
+ |
FinalizableDelegatedExecutorService(ExecutorService executor) { |
621 |
+ |
super(executor); |
622 |
+ |
} |
623 |
|
protected void finalize() { |
624 |
< |
e.shutdown(); |
624 |
> |
super.shutdown(); |
625 |
|
} |
619 |
– |
|
626 |
|
} |
627 |
+ |
|
628 |
|
|
629 |
|
/** |
630 |
|
* A wrapper class that exposes only the ScheduledExecutorService |