22 |
|
* <p> <b>Extension example</b>. Here is a sketch of a class |
23 |
|
* that customizes {@link ThreadPoolExecutor} to use |
24 |
|
* a <tt>CustomTask</tt> class instead of the default <tt>FutureTask</tt>: |
25 |
< |
* <pre> |
25 |
> |
* <pre> {@code |
26 |
|
* public class CustomThreadPoolExecutor extends ThreadPoolExecutor { |
27 |
|
* |
28 |
< |
* static class CustomTask<V> implements RunnableFuture<V> {...} |
28 |
> |
* static class CustomTask<V> implements RunnableFuture<V> {...} |
29 |
|
* |
30 |
< |
* protected <V> RunnableFuture<V> newTaskFor(Callable<V> c) { |
31 |
< |
* return new CustomTask<V>(c); |
30 |
> |
* protected <V> RunnableFuture<V> newTaskFor(Callable<V> c) { |
31 |
> |
* return new CustomTask<V>(c); |
32 |
|
* } |
33 |
< |
* protected <V> RunnableFuture<V> newTaskFor(Runnable r, V v) { |
34 |
< |
* return new CustomTask<V>(r, v); |
33 |
> |
* protected <V> RunnableFuture<V> newTaskFor(Runnable r, V v) { |
34 |
> |
* return new CustomTask<V>(r, v); |
35 |
|
* } |
36 |
|
* // ... add constructors, etc. |
37 |
< |
* } |
38 |
< |
* </pre> |
37 |
> |
* }}</pre> |
38 |
> |
* |
39 |
|
* @since 1.5 |
40 |
|
* @author Doug Lea |
41 |
|
*/ |