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.33 by jsr166, Fri Mar 24 05:51:49 2006 UTC vs.
Revision 1.34 by jsr166, Mon Sep 20 20:23:52 2010 UTC

# Line 18 | Line 18 | package java.util.concurrent;
18   * computation has completed, the computation cannot be cancelled.
19   * If you would like to use a <tt>Future</tt> for the sake
20   * of cancellability but not provide a usable result, you can
21 < * declare types of the form <tt>Future&lt;?&gt;</tt> and
21 > * declare types of the form {@code Future<?>} and
22   * return <tt>null</tt> as a result of the underlying task.
23   *
24   * <p>
25   * <b>Sample Usage</b> (Note that the following classes are all
26   * made-up.) <p>
27 < * <pre>
27 > *  <pre> {@code
28   * interface ArchiveSearcher { String search(String target); }
29   * class App {
30   *   ExecutorService executor = ...
31   *   ArchiveSearcher searcher = ...
32   *   void showSearch(final String target)
33   *       throws InterruptedException {
34 < *     Future&lt;String&gt; future
35 < *       = executor.submit(new Callable&lt;String&gt;() {
34 > *     Future<String> future
35 > *       = executor.submit(new Callable<String>() {
36   *         public String call() {
37   *             return searcher.search(target);
38   *         }});
# Line 41 | Line 41 | package java.util.concurrent;
41   *       displayText(future.get()); // use future
42   *     } catch (ExecutionException ex) { cleanup(); return; }
43   *   }
44 < * }
45 < * </pre>
44 > * }}</pre>
45   *
46   * The {@link FutureTask} class is an implementation of <tt>Future</tt> that
47   * implements <tt>Runnable</tt>, and so may be executed by an <tt>Executor</tt>.
48   * For example, the above construction with <tt>submit</tt> could be replaced by:
49 < * <pre>
50 < *     FutureTask&lt;String&gt; future =
51 < *       new FutureTask&lt;String&gt;(new Callable&lt;String&gt;() {
49 > *  <pre> {@code
50 > *     FutureTask<String> future =
51 > *       new FutureTask<String>(new Callable<String>() {
52   *         public String call() {
53   *           return searcher.search(target);
54   *       }});
55 < *     executor.execute(future);
57 < * </pre>
55 > *     executor.execute(future);}</pre>
56   *
57   * <p>Memory consistency effects: Actions taken by the asynchronous computation
58   * <a href="package-summary.html#MemoryVisibility"> <i>happen-before</i></a>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines