mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add PushService for DruidMonitor
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.alibaba.druid.util;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* @author sandzhang<sandzhangtoo@gmail.com>
|
||||
*/
|
||||
public class DaemonThreadFactory implements ThreadFactory {
|
||||
|
||||
private AtomicInteger threadNo = new AtomicInteger(1);
|
||||
private final String nameStart;
|
||||
private final String nameEnd = "]";
|
||||
|
||||
public DaemonThreadFactory(String poolName){
|
||||
nameStart = "[" + poolName + "-";
|
||||
}
|
||||
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread newThread = new Thread(r, nameStart + threadNo.getAndIncrement() + nameEnd);
|
||||
newThread.setDaemon(true);
|
||||
if (newThread.getPriority() != Thread.NORM_PRIORITY) {
|
||||
newThread.setPriority(Thread.NORM_PRIORITY);
|
||||
}
|
||||
return newThread;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user