mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
修改 ThreadUtil.newExecutor 创建线程池返回类
This commit is contained in:
parent
9ddb271f2e
commit
1d48ead94c
@ -35,7 +35,7 @@ public class ThreadUtil {
|
||||
* @param corePoolSize 同时执行的线程数大小
|
||||
* @return ExecutorService
|
||||
*/
|
||||
public static ExecutorService newExecutor(int corePoolSize) {
|
||||
public static ThreadPoolExecutor newExecutor(int corePoolSize) {
|
||||
ExecutorBuilder builder = ExecutorBuilder.create();
|
||||
if (corePoolSize > 0) {
|
||||
builder.setCorePoolSize(corePoolSize);
|
||||
|
@ -4,8 +4,19 @@ import cn.hutool.core.util.RandomUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
public class ThreadUtilTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void newExecutorTest(){
|
||||
ThreadPoolExecutor executor = ThreadUtil.newExecutor(5);
|
||||
// 查询线程池 线程数
|
||||
Assert.assertEquals(5, executor.getCorePoolSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void executeTest() {
|
||||
final boolean isValid = true;
|
||||
|
Loading…
Reference in New Issue
Block a user