forked from Archives/Athou_commafeed
use default thread factory
This commit is contained in:
@@ -2,10 +2,8 @@ package com.commafeed.backend.feeds;
|
|||||||
|
|
||||||
import java.util.concurrent.LinkedBlockingDeque;
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
import java.util.concurrent.RejectedExecutionHandler;
|
import java.util.concurrent.RejectedExecutionHandler;
|
||||||
import java.util.concurrent.ThreadFactory;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -55,7 +53,6 @@ public class FeedRefreshExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pool.setThreadFactory(new NamedThreadFactory(poolName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(Task task) {
|
public void execute(Task task) {
|
||||||
@@ -84,25 +81,4 @@ public class FeedRefreshExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class NamedThreadFactory implements ThreadFactory {
|
|
||||||
private final ThreadGroup group;
|
|
||||||
private final AtomicInteger threadNumber = new AtomicInteger(1);
|
|
||||||
private final String namePrefix;
|
|
||||||
|
|
||||||
private NamedThreadFactory(String poolName) {
|
|
||||||
SecurityManager s = System.getSecurityManager();
|
|
||||||
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
|
|
||||||
namePrefix = poolName + "-thread-";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Thread newThread(Runnable r) {
|
|
||||||
Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
|
|
||||||
if (t.isDaemon())
|
|
||||||
t.setDaemon(false);
|
|
||||||
if (t.getPriority() != Thread.NORM_PRIORITY)
|
|
||||||
t.setPriority(Thread.NORM_PRIORITY);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user