本文整理汇总了Java中java.util.concurrent.ForkJoinWorkerThread.setName方法的典型用法代码示例。如果您正苦于以下问题:Java ForkJoinWorkerThread.setName方法的具体用法?Java ForkJoinWorkerThread.setName怎么用?Java ForkJoinWorkerThread.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.ForkJoinWorkerThread
的用法示例。
在下文中一共展示了ForkJoinWorkerThread.setName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExecutor
import java.util.concurrent.ForkJoinWorkerThread; //导入方法依赖的package包/类
ExecutorService getExecutor(int asyncThreads) {
// TODO(carl-mastrangelo): This should not be necessary. I don't know where this should be
// put. Move it somewhere else, or remove it if no longer necessary.
// See: https://github.com/grpc/grpc-java/issues/2119
return new ForkJoinPool(asyncThreads,
new ForkJoinWorkerThreadFactory() {
final AtomicInteger num = new AtomicInteger();
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
ForkJoinWorkerThread thread = defaultForkJoinWorkerThreadFactory.newThread(pool);
thread.setDaemon(true);
thread.setName("server-worker-" + "-" + num.getAndIncrement());
return thread;
}
}, UncaughtExceptionHandlers.systemExit(), true /* async */);
}
示例2: usingWorkStealingPool
import java.util.concurrent.ForkJoinWorkerThread; //导入方法依赖的package包/类
public void usingWorkStealingPool() {
if (executeService != null) return;
ForkJoinPool.ForkJoinWorkerThreadFactory threadFactory = new ForkJoinPool.ForkJoinWorkerThreadFactory() {
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
ForkJoinWorkerThread result = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
if (result != null) result.setName(String.format("[%s_%04d]", executeFactoryName, result.getId()));
return result;
}
};
executeService = new ForkJoinPool(usingThreadCount, threadFactory, null, true);
}
示例3: newThread
import java.util.concurrent.ForkJoinWorkerThread; //导入方法依赖的package包/类
@Override
public ForkJoinWorkerThread newThread(final ForkJoinPool pool) {
final ForkJoinWorkerThread result = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
result.setPriority(priority);
result.setName(this.allThreads.getName() + " #" + threadCount.incrementAndGet());
return result;
}
示例4: fjwtf
import java.util.concurrent.ForkJoinWorkerThread; //导入方法依赖的package包/类
private static ForkJoinWorkerThreadFactory fjwtf(final String name) {
AtomicLong id = new AtomicLong();
return pool -> {
ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
thread.setName(name + "-" + id.incrementAndGet());
return thread;
};
}
示例5: newThread
import java.util.concurrent.ForkJoinWorkerThread; //导入方法依赖的package包/类
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
final int n = setNextBit();
ForkJoinWorkerThread thread = new ForkJoinWorkerThread(pool) {
@Override
protected void onTermination(Throwable exception) {
clearBit(n);
super.onTermination(exception);
}
};
thread.setName("JobScheduler FJ pool " + n + "/" + PARALLELISM);
thread.setPriority(Thread.NORM_PRIORITY - 1);
return thread;
}
示例6: newThread
import java.util.concurrent.ForkJoinWorkerThread; //导入方法依赖的package包/类
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
thread.setName(NAME_PREFIX + i++);
return thread;
}
示例7: newThread
import java.util.concurrent.ForkJoinWorkerThread; //导入方法依赖的package包/类
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
worker.setName(namePrefix + worker.getPoolIndex());
return worker;
}
示例8: newThread
import java.util.concurrent.ForkJoinWorkerThread; //导入方法依赖的package包/类
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
thread.setName(prefix + "-ForkJoinPool-worker-" + nextThreadNum());
return thread;
}