6 |
|
|
7 |
|
package java.util.concurrent; |
8 |
|
|
9 |
– |
import java.security.AccessControlContext; |
10 |
– |
import java.security.AccessController; |
11 |
– |
import java.security.PrivilegedAction; |
12 |
– |
import java.security.PrivilegedExceptionAction; |
9 |
|
import java.util.*; |
14 |
– |
import java.util.concurrent.locks.*; |
10 |
|
|
11 |
|
/** |
12 |
|
* Provides default implementation of {@link ExecutorService} |
13 |
< |
* execution methods. This class implements the <tt>submit</tt> and |
14 |
< |
* <tt>invoke</tt> methods using the default {@link FutureTask} and |
15 |
< |
* {@link PrivilegedFutureTask} classes provided in this package. For |
16 |
< |
* example, the the implementation of <tt>submit(Runnable)</tt> |
17 |
< |
* creates an associated <tt>FutureTask</tt> that is executed and |
13 |
> |
* execution methods. This class implements the <tt>submit</tt>, |
14 |
> |
* <tt>invokeAny</tt> and <tt>invokeAll</tt> methods using the default |
15 |
> |
* {@link FutureTask} class provided in this package. For example, |
16 |
> |
* the the implementation of <tt>submit(Runnable)</tt> creates an |
17 |
> |
* associated <tt>FutureTask</tt> that is executed and |
18 |
|
* returned. Subclasses overriding these methods to use different |
19 |
|
* {@link Future} implementations should do so consistently for each |
20 |
|
* of these methods. |
36 |
|
return ftask; |
37 |
|
} |
38 |
|
|
44 |
– |
public <T> T invoke(Callable<T> task) throws ExecutionException, InterruptedException { |
45 |
– |
FutureTask<T> ftask = new FutureTask<T>(task); |
46 |
– |
execute(ftask); |
47 |
– |
return ftask.get(); |
48 |
– |
} |
49 |
– |
|
39 |
|
// any/all methods, each a little bit different than the other |
40 |
|
|
41 |
|
|