List of usage examples for java.util.concurrent ForkJoinWorkerThread setName
public final synchronized void setName(String name)
From source file:org.openstreetmap.josm.tools.Utils.java
/** * Returns a {@link ForkJoinPool} with the parallelism given by the preference key. * @param pref The preference key to determine parallelism * @param nameFormat see {@link #newThreadFactory(String, int)} * @param threadPriority see {@link #newThreadFactory(String, int)} * @return a {@link ForkJoinPool}/*from w ww. j a v a 2 s. c o m*/ */ public static ForkJoinPool newForkJoinPool(String pref, final String nameFormat, final int threadPriority) { int noThreads = Main.pref.getInteger(pref, Runtime.getRuntime().availableProcessors()); return new ForkJoinPool(noThreads, new ForkJoinPool.ForkJoinWorkerThreadFactory() { final AtomicLong count = new AtomicLong(0); @Override public ForkJoinWorkerThread newThread(ForkJoinPool pool) { final ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); thread.setName(String.format(Locale.ENGLISH, nameFormat, count.getAndIncrement())); thread.setPriority(threadPriority); return thread; } }, null, true); }