|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.xiaoleilu.hutool.ThreadUtil
public class ThreadUtil
线程池工具
| 构造方法摘要 | |
|---|---|
ThreadUtil()
|
|
| 方法摘要 | ||
|---|---|---|
static Runnable |
excAsync(Runnable runnable,
boolean isDeamon)
执行异步方法 |
|
static
|
execAsync(Callable<T> task)
执行有返回值的异步方法 Future代表一个异步执行的操作,通过get()方法可以获得操作的结果,如果异步操作还没有完成,则,get()会使当前线程阻塞 |
|
static void |
execute(Runnable runnable)
直接在公共线程池中执行线程 |
|
static
|
newCompletionService()
新建一个CompletionService,调用其submit方法可以异步执行多个任务,最后调用take方法按照完成的顺序获得其结果。 |
|
static
|
newCompletionService(ExecutorService executor)
新建一个CompletionService,调用其submit方法可以异步执行多个任务,最后调用take方法按照完成的顺序获得其结果。 |
|
static CountDownLatch |
newCountDownLatch(int threadCount)
|
|
static ExecutorService |
newExecutor()
获得一个新的线程池 |
|
static ExecutorService |
newExecutor(int threadSize)
新建一个线程池 |
|
static void |
restart()
重启公共线程池 |
|
static boolean |
sleep(Long millis)
挂起当前线程 |
|
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public ThreadUtil()
| 方法详细信息 |
|---|
public static void execute(Runnable runnable)
runnable - 可运行对象public static void restart()
public static ExecutorService newExecutor(int threadSize)
threadSize - 同时执行的线程数大小
public static ExecutorService newExecutor()
public static Runnable excAsync(Runnable runnable,
boolean isDeamon)
runnable - 需要执行的方法体
public static <T> Future<T> execAsync(Callable<T> task)
public static <T> CompletionService<T> newCompletionService()
public static <T> CompletionService<T> newCompletionService(ExecutorService executor)
public static CountDownLatch newCountDownLatch(int threadCount)
public static boolean sleep(Long millis)
millis - 挂起的毫秒数
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||