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

Comparing jsr166/src/main/java/util/concurrent/Future.java (file contents):
Revision 1.17 by dl, Thu Dec 4 20:54:29 2003 UTC vs.
Revision 1.18 by tim, Wed Dec 10 17:01:58 2003 UTC

# Line 23 | Line 23 | package java.util.concurrent;
23   * <pre>
24   * interface ArchiveSearcher { String search(String target); }
25   * class App {
26 < *   Executor executor = ...
26 > *   ExecutorService executor = ...
27   *   ArchiveSearcher searcher = ...
28   *   void showSearch(final String target) throws InterruptedException {
29 < *     Future&lt;String&gt; future =
30 < *       new FutureTask&lt;String&gt;(new Callable&lt;String&gt;() {
31 < *         public String call() {
32 < *           return searcher.search(target);
33 < *       }});
34 < *     executor.execute(future);
29 > *     Future&lt;String&gt; future = executor.submit(new Callable&lt;String&gt;() {
30 > *         public String call() { return searcher.search(target); }
31 > *     });
32   *     displayOtherThings(); // do other things while searching
33   *     try {
34   *       displayText(future.get()); // use future
# Line 40 | Line 37 | package java.util.concurrent;
37   * }
38   * </pre>
39   *
40 < * The {@link Executors} class contains more convenient methods
41 < * for common usages. For example, the above explicit
42 < * construction could be replaced with:
40 > * The {@link FutureTask} class is an implementation of <tt>Future</tt> that
41 > * implements <tt>Runnable</tt>, and so may be executed by an <tt>Executor</tt>.
42 > * For example, the above construction with <tt>submit</tt> could be replaced by:
43   * <pre>
44 < * Future&lt;String&gt; future = Executors.execute(executor,
45 < *    new Callable&lt;String&gt;() {
46 < *       public String call() {
47 < *         return searcher.search(target);
48 < *    }});
44 > *     FutureTask&lt;String&gt; future =
45 > *       new FutureTask&lt;String&gt;(new Callable&lt;String&gt;() {
46 > *         public String call() {
47 > *           return searcher.search(target);
48 > *       }});
49 > *     executor.execute(future);
50   * </pre>
51   * @see FutureTask
52   * @see Executor

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines