250 |
|
* for execution |
251 |
|
*/ |
252 |
|
public static Future<Object> execute(Executor executor, PrivilegedAction action) { |
253 |
– |
return execute(executor, action, AccessController.getContext()); |
254 |
– |
} |
255 |
– |
|
256 |
– |
/** |
257 |
– |
* Executes a privileged action under the given access control |
258 |
– |
* context and returns a Future representing the pending result |
259 |
– |
* object of that action. |
260 |
– |
* |
261 |
– |
* @param executor the Executor to which the task will be submitted |
262 |
– |
* @param action the action to submit |
263 |
– |
* @param acc the access control context under which action should run |
264 |
– |
* @return a Future representing pending completion of the action |
265 |
– |
* @throws RejectedExecutionException if action cannot be scheduled |
266 |
– |
* for execution |
267 |
– |
*/ |
268 |
– |
public static Future<Object> execute(Executor executor, PrivilegedAction action, |
269 |
– |
AccessControlContext acc) { |
253 |
|
Callable<Object> task = new PrivilegedActionAdapter(action); |
254 |
< |
FutureTask<Object> future = new PrivilegedFutureTask<Object>(task, acc); |
254 |
> |
FutureTask<Object> future = new PrivilegedFutureTask<Object>(task); |
255 |
|
executor.execute(future); |
256 |
|
return future; |
257 |
|
} |
268 |
|
* for execution |
269 |
|
*/ |
270 |
|
public static Future<Object> execute(Executor executor, PrivilegedExceptionAction action) { |
288 |
– |
return execute(executor, action, AccessController.getContext()); |
289 |
– |
} |
290 |
– |
|
291 |
– |
/** |
292 |
– |
* Executes a privileged exception action under the given access control |
293 |
– |
* context and returns a Future representing the pending result |
294 |
– |
* object of that action. |
295 |
– |
* |
296 |
– |
* @param executor the Executor to which the task will be submitted |
297 |
– |
* @param action the action to submit |
298 |
– |
* @param acc the access control context under which action should run |
299 |
– |
* @return a Future representing pending completion of the action |
300 |
– |
* @throws RejectedExecutionException if action cannot be scheduled |
301 |
– |
* for execution |
302 |
– |
*/ |
303 |
– |
public static Future<Object> execute(Executor executor, PrivilegedExceptionAction action, |
304 |
– |
AccessControlContext acc) { |
271 |
|
Callable<Object> task = new PrivilegedExceptionActionAdapter(action); |
272 |
< |
FutureTask<Object> future = new PrivilegedFutureTask<Object>(task, acc); |
272 |
> |
FutureTask<Object> future = new PrivilegedFutureTask<Object>(task); |
273 |
|
executor.execute(future); |
274 |
|
return future; |
275 |
|
} |