ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/AbstractExecutorService.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/AbstractExecutorService.java (file contents):
Revision 1.21 by peierls, Tue May 17 04:17:05 2005 UTC vs.
Revision 1.22 by dl, Tue May 17 13:08:08 2005 UTC

# Line 20 | Line 20 | import java.util.*;
20   * to return other <tt>RunnableFuture</tt> implementations than
21   * <tt>FutureTask</tt>.
22   *
23 + * <p> <b>Extension example</b>. Here is a sketch of a class
24 + * that customizes {@link ThreadPoolExecutor} to use
25 + * a <tt>CustomTask</tt> class instead of the default <tt>FutureTask</tt>:
26 + * <pre>
27 + * public class CustomThreadPoolExecutor extends ThreadPoolExecutor {
28 + *
29 + *     static class CustomTask&lt;V&gt; implements RunnableFuture&lt;V&gt; {...}
30 + *
31 + *    &lt;V&gt; protected RunnableFuture&lt;V&gt; newTaskFor(Callable&lt;V&gt; c) {
32 + *         return new CustomTask&lt;V&gt;(c);
33 + *     }
34 + *    &lt;V&gt; protected RunnableFuture&lt;V&gt; newTaskFor(Runnable r, V v) {
35 + *         return new CustomTask&lt;V&gt;(r, v);
36 + *     }
37 + *     // ... add constructors, etc.
38 + * }
39 + * </pre>
40   * @since 1.5
41   * @author Doug Lea
42   */
# Line 30 | Line 47 | public abstract class AbstractExecutorSe
47       * value.
48       * @param runnable the runnable task being wrapped
49       * @param value the default value for the returned future
50 <     * @return a RunnableFuture which when run will run the underlying
51 <     * runnable and which, as a Future, will yield the given value as its result
52 <     * and provide for cancellation of the underlying task.
50 >     * @return a <tt>RunnableFuture</tt> which when run will run the
51 >     * underlying runnable and which, as a <tt>Future</tt>, will yield
52 >     * the given value as its result and provide for cancellation of
53 >     * the underlying task.
54 >     * @since 1.6
55       */
56      protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {
57          return new FutureTask<T>(runnable, value);
# Line 41 | Line 60 | public abstract class AbstractExecutorSe
60      /**
61       * Returns a <tt>RunnableFuture</tt> for the given callable task.
62       * @param callable the callable task being wrapped
63 <     * @return a RunnableFuture which when run will call the underlying
64 <     * callable and which, as a Future, will yield the callable's result
65 <     * as its result and provide for cancellation of the underlying task.
63 >     * @return a <tt>RunnableFuture</tt> which when run will call the
64 >     * underlying callable and which, as a <tt>Future</tt>, will yield
65 >     * the callable's result as its result and provide for
66 >     * cancellation of the underlying task.
67 >     * @since 1.6
68       */
69      protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
70          return new FutureTask<T>(callable);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines