本文整理汇总了Java中EDU.oswego.cs.dl.util.concurrent.ThreadFactory类的典型用法代码示例。如果您正苦于以下问题:Java ThreadFactory类的具体用法?Java ThreadFactory怎么用?Java ThreadFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ThreadFactory类属于EDU.oswego.cs.dl.util.concurrent包,在下文中一共展示了ThreadFactory类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeThreadPool
import EDU.oswego.cs.dl.util.concurrent.ThreadFactory; //导入依赖的package包/类
public static PooledExecutor makeThreadPool(final int keepAlive, final int maxPoolSize, final int initialThreadCount, final String threadNamePrefix) {
final PooledExecutor result = new PooledExecutor();
result.setThreadFactory(new ThreadFactory() {
private int createdThreadCount = 0;
/**
* Creates a new thread.
*
* @param runnable
*/
public Thread newThread(final Runnable runnable) {
return makeDaemonThread(runnable, threadNamePrefix + '-' + createdThreadCount++);
}
});
result.setKeepAliveTime(keepAlive);
result.setMaximumPoolSize(maxPoolSize);
result.setMinimumPoolSize(1);
result.createThreads(initialThreadCount);
return result;
}
示例2: AgentManager
import EDU.oswego.cs.dl.util.concurrent.ThreadFactory; //导入依赖的package包/类
/**
* Singleton constructor.
*/
private AgentManager() {
// Create upgrade executor queue
final int poolSize = SystemConfigurationManagerFactory.getManager().getMaxParallelSystemUpgrades();
agentUpgradeExecutor = new PooledExecutor(new LinkedQueue(), poolSize);
agentUpgradeExecutor.setThreadFactory(new ThreadFactory() {
public Thread newThread(final Runnable command) {
return ThreadUtils.makeDaemonThread(command, "AgentUpgrader");
}
});
agentUpgradeExecutor.setKeepAliveTime(-1L); // live forever
}
示例3: initTaskManager
import EDU.oswego.cs.dl.util.concurrent.ThreadFactory; //导入依赖的package包/类
/**
* Initializes task manager.
*/
private void initTaskManager() {
executor = new PooledExecutor(new LinkedQueue(), 10);
executor.setThreadFactory(new ThreadFactory() {
public Thread newThread(final Runnable runnable) {
return ThreadUtils.makeDaemonThread(runnable, "ParabuildTaskRunnerThread");
}
});
executor.setKeepAliveTime(-1); // live forever
}