MCPcopy Create free account
hub / github.com/aofeng/threadpool4j / ThreadPool

Interface ThreadPool

src/cn/aofeng/threadpool4j/ThreadPool.java:13–162  ·  view source on GitHub ↗

线程池。 @author 聂勇

Source from the content-addressed store, hash-verified

11 * @author <a href="mailto:aofengblog@163.com">聂勇</a>
12 */
13public interface ThreadPool {
14
15 /**
16 * 提交一个不需要返回值的异步任务给默认的线程池执行。
17 *
18 * @param task 实现了{@link Runnable}接口的异步任务
19 * @return 异步任务执行的结果
20 * @throws IllegalArgumentException 指定的任务(&lt;code&gt;task&lt;/code&gt;)为null
21 * @throws RejectedExecutionException 当队列满,异步任务无法提交给线程池执行时抛出此异常
22 * @see #submit(Runnable, String)
23 */
24 public Future<?> submit(Runnable task) throws RejectedExecutionException;
25
26 /**
27 * 提交一个不需要返回值的异步任务给指定的线程池执行。
28 *
29 * @param task 实现了{@link Runnable}接口的异步任务
30 * @param threadpoolName 线程池名称
31 * @return 异步任务执行的结果
32 * @throws IllegalArgumentException 出现以下情况时抛出:
33 * &lt;ul&gt;
34 * &lt;li&gt;指定的任务(&lt;code&gt;task&lt;/code&gt;)为null;&lt;/li&gt;
35 * &lt;li&gt;指定的线程池名称(&lt;code&gt;threadpoolName&lt;/code&gt;)为null,""或全是空白字符;&lt;/li&gt;
36 * &lt;li&gt;指定的线程池不存在。&lt;/li&gt;
37 * &lt;/ul&gt;
38 * @throws RejectedExecutionException 当队列满,异步任务无法提交给线程池执行时抛出此异常
39 */
40 public Future<?> submit(Runnable task, String threadpoolName) throws RejectedExecutionException;
41
42 /**
43 * 提交一个不需要返回值的异步任务给指定的线程池执行。
44 *
45 * @param task 实现了{@link Runnable}接口的异步任务
46 * @param threadpoolName 线程池名称
47 * @param failHandler 当队列满,异步任务无法提交给线程池执行的"失败处理器"
48 * @return 异步任务执行的结果。如果队列满导致任务无法提交,将返回null
49 * @throws IllegalArgumentException 出现以下情况时抛出:
50 * &lt;ul&gt;
51 * &lt;li&gt;指定的任务(&lt;code&gt;task&lt;/code&gt;)为null;&lt;/li&gt;
52 * &lt;li&gt;指定的线程池名称(&lt;code&gt;threadpoolName&lt;/code&gt;)为null,""或全是空白字符;&lt;/li&gt;
53 * &lt;li&gt;指定的线程池不存在。&lt;/li&gt;
54 * &lt;/ul&gt;
55 */
56 public Future<?> submit(Runnable task, String threadpoolName,
57 FailHandler<Runnable> failHandler);
58
59 /**
60 * 提交一个需要返回值的异步任务给默认的线程池执行。
61 *
62 * @param task 实现了{@link Callable}接口的异步任务
63 * @return 异步任务执行的结果
64 * @param <T> 异步任务执行的结果类型
65 * @throws IllegalArgumentException 指定的任务(&lt;code&gt;task&lt;/code&gt;)为null
66 * @throws RejectedExecutionException 当队列满,异步任务无法提交给线程池执行时抛出此异常
67 * @see #submit(Callable, String)
68 */
69 public <T> Future<T> submit(Callable<T> task);
70

Implementers 1

ThreadPoolImplsrc/cn/aofeng/threadpool4j/ThreadPoolI

Calls

no outgoing calls

Tested by

no test coverage detected