ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/Callable.java
Revision: 1.12
Committed: Wed Dec 4 12:30:14 2013 UTC (10 years, 6 months ago) by dl
Branch: MAIN
CVS Tags: HEAD
Changes since 1.11: +1 -0 lines
Log Message:
add FunctionalInterface

File Contents

# User Rev Content
1 tim 1.1 /*
2 dl 1.2 * Written by Doug Lea with assistance from members of JCP JSR-166
3 dl 1.8 * Expert Group and released to the public domain, as explained at
4 jsr166 1.9 * http://creativecommons.org/publicdomain/zero/1.0/
5 tim 1.1 */
6    
7     package java.util.concurrent;
8    
9     /**
10 dl 1.4 * A task that returns a result and may throw an exception.
11     * Implementors define a single method with no arguments called
12 jsr166 1.11 * {@code call}.
13 tim 1.1 *
14 jsr166 1.11 * <p>The {@code Callable} interface is similar to {@link
15 dl 1.5 * java.lang.Runnable}, in that both are designed for classes whose
16     * instances are potentially executed by another thread. A
17 jsr166 1.11 * {@code Runnable}, however, does not return a result and cannot
18 dl 1.5 * throw a checked exception.
19 tim 1.1 *
20 jsr166 1.10 * <p>The {@link Executors} class contains utility methods to
21 jsr166 1.11 * convert from other common forms to {@code Callable} classes.
22 dl 1.7 *
23 tim 1.1 * @see Executor
24 dl 1.5 * @since 1.5
25 dl 1.4 * @author Doug Lea
26 jsr166 1.11 * @param <V> the result type of method {@code call}
27 tim 1.1 */
28 dl 1.12 @FunctionalInterface
29 tim 1.1 public interface Callable<V> {
30     /**
31     * Computes a result, or throws an exception if unable to do so.
32     *
33     * @return computed result
34     * @throws Exception if unable to compute a result
35     */
36     V call() throws Exception;
37     }