81 |
|
* <tt>newFixedThreadPool(1)</tt> the returned executor is |
82 |
|
* guaranteed not to be reconfigurable to use additional threads. |
83 |
|
* |
84 |
< |
* @return the newly-created single-threaded Executor |
84 |
> |
* @return the newly created single-threaded Executor |
85 |
|
*/ |
86 |
|
public static ExecutorService newSingleThreadExecutor() { |
87 |
|
return new DelegatedExecutorService |
101 |
|
* @param threadFactory the factory to use when creating new |
102 |
|
* threads |
103 |
|
* |
104 |
< |
* @return the newly-created single-threaded Executor |
104 |
> |
* @return the newly created single-threaded Executor |
105 |
|
*/ |
106 |
|
public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory) { |
107 |
|
return new DelegatedExecutorService |
159 |
|
* given time. Unlike the otherwise equivalent |
160 |
|
* <tt>newScheduledThreadPool(1)</tt> the returned executor is |
161 |
|
* guaranteed not to be reconfigurable to use additional threads. |
162 |
< |
* @return a newly created scheduled executor |
162 |
> |
* @return the newly created scheduled executor |
163 |
|
*/ |
164 |
|
public static ScheduledExecutorService newSingleThreadScheduledExecutor() { |
165 |
|
return new DelegatedScheduledExecutorService |
195 |
|
*/ |
196 |
|
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize) { |
197 |
|
return new ScheduledThreadPoolExecutor(corePoolSize); |
198 |
< |
} |
198 |
> |
} |
199 |
|
|
200 |
|
/** |
201 |
|
* Creates a thread pool that can schedule commands to run after a |
213 |
|
|
214 |
|
|
215 |
|
/** |
216 |
< |
* Creates and returns an object that delegates all defined {@link |
216 |
> |
* Returns an object that delegates all defined {@link |
217 |
|
* ExecutorService} methods to the given executor, but not any |
218 |
|
* other methods that might otherwise be accessible using |
219 |
|
* casts. This provides a way to safely "freeze" configuration and |
229 |
|
} |
230 |
|
|
231 |
|
/** |
232 |
< |
* Creates and returns an object that delegates all defined {@link |
232 |
> |
* Returns an object that delegates all defined {@link |
233 |
|
* ScheduledExecutorService} methods to the given executor, but |
234 |
|
* not any other methods that might otherwise be accessible using |
235 |
|
* casts. This provides a way to safely "freeze" configuration and |
257 |
|
* <em>pool-N-thread-M</em>, where <em>N</em> is the sequence |
258 |
|
* number of this factory, and <em>M</em> is the sequence number |
259 |
|
* of the thread created by this factory. |
260 |
< |
* @return the thread factory |
260 |
> |
* @return a thread factory |
261 |
|
*/ |
262 |
|
public static ThreadFactory defaultThreadFactory() { |
263 |
|
return new DefaultThreadFactory(); |
290 |
|
* thread waits for and services requests to create others that |
291 |
|
* will inherit its values. |
292 |
|
* |
293 |
< |
* @return the thread factory |
293 |
> |
* @return a thread factory |
294 |
|
* @throws AccessControlException if the current access control |
295 |
|
* context does not have permission to both get and set context |
296 |
|
* class loader. |
301 |
|
|
302 |
|
|
303 |
|
/** |
304 |
< |
* Creates and returns a {@link Callable} object that, when |
304 |
> |
* Returns a {@link Callable} object that, when |
305 |
|
* called, runs the given task and returns the given result. This |
306 |
|
* can be useful when applying methods requiring a |
307 |
|
* <tt>Callable</tt> to an otherwise resultless action. |
308 |
|
* @param task the task to run |
309 |
|
* @param result the result to return |
310 |
|
* @throws NullPointerException if task null |
311 |
< |
* @return callable object |
311 |
> |
* @return a callable object |
312 |
|
*/ |
313 |
|
public static <T> Callable<T> callable(Runnable task, T result) { |
314 |
|
if (task == null) |
317 |
|
} |
318 |
|
|
319 |
|
/** |
320 |
< |
* Creates and returns a {@link Callable} object that, when |
320 |
> |
* Returns a {@link Callable} object that, when |
321 |
|
* called, runs the given task and returns <tt>null</tt> |
322 |
|
* @param task the task to run |
323 |
< |
* @return callable object |
323 |
> |
* @return a callable object |
324 |
|
* @throws NullPointerException if task null |
325 |
|
*/ |
326 |
|
public static Callable<Object> callable(Runnable task) { |
330 |
|
} |
331 |
|
|
332 |
|
/** |
333 |
< |
* Creates and returns a {@link Callable} object that, when |
333 |
> |
* Returns a {@link Callable} object that, when |
334 |
|
* called, runs the given privileged action and returns its result |
335 |
|
* @param action the privileged action to run |
336 |
< |
* @return callable object |
336 |
> |
* @return a callable object |
337 |
|
* @throws NullPointerException if action null |
338 |
|
*/ |
339 |
|
public static Callable<Object> callable(PrivilegedAction action) { |
343 |
|
} |
344 |
|
|
345 |
|
/** |
346 |
< |
* Creates and returns a {@link Callable} object that, when |
346 |
> |
* Returns a {@link Callable} object that, when |
347 |
|
* called, runs the given privileged exception action and returns |
348 |
|
* its result |
349 |
|
* @param action the privileged exception action to run |
350 |
< |
* @return callable object |
350 |
> |
* @return a callable object |
351 |
|
* @throws NullPointerException if action null |
352 |
|
*/ |
353 |
|
public static Callable<Object> callable(PrivilegedExceptionAction action) { |
357 |
|
} |
358 |
|
|
359 |
|
/** |
360 |
< |
* Creates and returns a {@link Callable} object that will, when |
360 |
> |
* Returns a {@link Callable} object that will, when |
361 |
|
* called, execute the given <tt>callable</tt> under the current |
362 |
|
* access control context. This method should normally be |
363 |
|
* invoked within an {@link AccessController#doPrivileged} action |
366 |
|
* not possible, throw an associated {@link |
367 |
|
* AccessControlException}. |
368 |
|
* @param callable the underlying task |
369 |
< |
* @return callable object |
369 |
> |
* @return a callable object |
370 |
|
* @throws NullPointerException if callable null |
371 |
|
* |
372 |
|
*/ |
377 |
|
} |
378 |
|
|
379 |
|
/** |
380 |
< |
* Creates and returns a {@link Callable} object that will, when |
380 |
> |
* Returns a {@link Callable} object that will, when |
381 |
|
* called, execute the given <tt>callable</tt> under the current |
382 |
|
* access control context, with the current context class loader |
383 |
|
* as the context class loader. This method should normally be |
388 |
|
* AccessControlException}. |
389 |
|
* @param callable the underlying task |
390 |
|
* |
391 |
< |
* @return callable object |
391 |
> |
* @return a callable object |
392 |
|
* @throws NullPointerException if callable null |
393 |
|
* @throws AccessControlException if the current access control |
394 |
|
* context does not have permission to both set and get context |
629 |
|
|
630 |
|
/** |
631 |
|
* A wrapper class that exposes only the ExecutorService and |
632 |
< |
* ScheduleExecutor methods of a ScheduledThreadPoolExecutor. |
632 |
> |
* ScheduleExecutor methods of a ScheduledExecutorService implementation. |
633 |
|
*/ |
634 |
|
static class DelegatedScheduledExecutorService |
635 |
|
extends DelegatedExecutorService |