Skip to content

Commit

Permalink
Add method newSingleExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Sep 15, 2014
1 parent 5467b71 commit e3255cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.xiaoleilu</groupId>
<artifactId>hutool</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<name>hutool</name>
<description>提供最基础的工具类</description>
<url>https://github.com/looly/hutool</url>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/xiaoleilu/hutool/ThreadUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;

import com.xiaoleilu.hutool.exceptions.UtilException;

Expand Down Expand Up @@ -54,6 +55,14 @@ public static ExecutorService newExecutor(){
return Executors.newCachedThreadPool();
}

/**
* 获得一个新的线程池,只有单个线程
* @return ExecutorService
*/
public static ExecutorService newSingleExecutor(){
return Executors.newSingleThreadExecutor();
}

/**
* 执行异步方法
* @param runnable 需要执行的方法体
Expand Down Expand Up @@ -97,6 +106,11 @@ public static<T> CompletionService<T> newCompletionService(ExecutorService execu
return new ExecutorCompletionService<T>(executor);
}

/**
* 新建一个CountDownLatch
* @param threadCount 线程数量
* @return CountDownLatch
*/
public static CountDownLatch newCountDownLatch(int threadCount) {
return new CountDownLatch(threadCount);
}
Expand Down

0 comments on commit e3255cc

Please sign in to comment.