mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-17 04:27:13 +00:00
ref[thread]: deprecated method in java 17
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user