ref[thread]: deprecated method in java 17

This commit is contained in:
godotg
2023-09-02 19:23:07 +08:00
parent e158e92497
commit b0d242658c
5 changed files with 5 additions and 13 deletions
@@ -71,7 +71,7 @@ public abstract class EventBus {
private final ThreadGroup group;
public EventThreadFactory(int poolNumber) {
this.group = ThreadUtils.currentThreadGroup();
this.group = Thread.currentThread().getThreadGroup();
this.poolNumber = poolNumber;
}
@@ -85,7 +85,7 @@ public class ZookeeperRegistry implements IRegistry {
// config-p1-t1 = config-pool-1-thread-1
ConfigThreadFactory() {
this.group = ThreadUtils.currentThreadGroup();
this.group = Thread.currentThread().getThreadGroup();
namePrefix = "config-p" + poolNumber.getAndIncrement() + "-t";
}
@@ -81,7 +81,7 @@ public final class TaskBus {
private final ThreadGroup group;
public TaskThreadFactory(int poolNumber) {
this.group = ThreadUtils.currentThreadGroup();
this.group = Thread.currentThread().getThreadGroup();
this.poolNumber = poolNumber;
}
@@ -78,7 +78,7 @@ public abstract class SchedulerBus {
private final ThreadGroup group;
public SchedulerThreadFactory(int poolNumber) {
this.group = ThreadUtils.currentThreadGroup();
this.group = Thread.currentThread().getThreadGroup();
this.poolNumber = poolNumber;
}
@@ -40,19 +40,11 @@ public abstract class ThreadUtils {
}
}
/**
* 获取当前线程的线程组
*/
public static ThreadGroup currentThreadGroup() {
var s = System.getSecurityManager();
return (null != s) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
}
/**
* 通过线程号寻找对应的线程
*/
public static Thread findThread(long threadId) {
var group = currentThreadGroup();
var group = Thread.currentThread().getThreadGroup();
while (group != null) {
var threads = new Thread[group.activeCount() * 2];
var count = group.enumerate(threads, true);