mirror of
https://gitee.com/dromara/hutool.git
synced 2026-02-09 09:16:26 +08:00
fix(ThreadUtil): 修复 getMainThread() 在 JDK 25 中返回 null 的问题 具体issues地址为:https://gitee.com/chinabugotech/hutool/issues/IDF4HN"
This commit is contained in:
@@ -25,6 +25,8 @@ import java.util.function.Supplier;
|
||||
* @author luxiaolei
|
||||
*/
|
||||
public class ThreadUtil {
|
||||
/** 主线程名称 **/
|
||||
public static final String MAIN_THREAD_NAME = "main";
|
||||
|
||||
/**
|
||||
* 新建一个线程池,默认的策略如下:
|
||||
@@ -551,7 +553,7 @@ public class ThreadUtil {
|
||||
*/
|
||||
public static Thread getMainThread() {
|
||||
for (Thread thread : getThreads()) {
|
||||
if (thread.getId() == 1) {
|
||||
if (MAIN_THREAD_NAME.equals(thread.getName())) {
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user