1 |
tim |
1.1 |
/* |
2 |
dl |
1.2 |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
|
* Expert Group and released to the public domain. Use, modify, and |
4 |
|
|
* redistribute this code in any way without acknowledgement. |
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 |
|
|
* <tt>call</tt>. |
13 |
tim |
1.1 |
* |
14 |
dl |
1.5 |
* <p>The <tt>Callable</tt> interface is similar to {@link |
15 |
|
|
* java.lang.Runnable}, in that both are designed for classes whose |
16 |
|
|
* instances are potentially executed by another thread. A |
17 |
|
|
* <tt>Runnable</tt>, however, does not return a result and cannot |
18 |
|
|
* throw a checked exception. |
19 |
tim |
1.1 |
* |
20 |
|
|
* @see Executor |
21 |
|
|
* @see FutureTask |
22 |
dl |
1.5 |
* @since 1.5 |
23 |
dl |
1.4 |
* @author Doug Lea |
24 |
tim |
1.1 |
*/ |
25 |
|
|
public interface Callable<V> { |
26 |
|
|
/** |
27 |
|
|
* Computes a result, or throws an exception if unable to do so. |
28 |
|
|
* |
29 |
|
|
* @return computed result |
30 |
|
|
* @throws Exception if unable to compute a result |
31 |
|
|
*/ |
32 |
|
|
V call() throws Exception; |
33 |
|
|
} |