Skip to content

Commit

Permalink
!1230 修改 ThreadUtil.newExecutor 创建线程池返回类
Browse files Browse the repository at this point in the history
Merge pull request !1230 from 温良恭/v5-dev
  • Loading branch information
looly authored and gitee-org committed Jun 30, 2024
2 parents 49dba65 + 1d48ead commit a8e959c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@
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;
Expand Down

0 comments on commit a8e959c

Please sign in to comment.