public Thread newThread(Runnable r) { String threadName = nameStart + threadNo.getAndIncrement() + nameEnd; Thread newThread = new Thread(r, threadName); newThread.setDaemon(true); if (newThread.getPriority() != Thread.NORM_PRIORITY) { newThread.setPriority(Thread.NORM_PRIORITY); } return newThread; }
@Override public Thread newThread(Runnable runnable) { Thread thread = backingThreadFactory.newThread(runnable); if (nameFormat != null) { thread.setName(format(nameFormat, count.getAndIncrement())); } if (daemon != null) { thread.setDaemon(daemon); } if (priority != null) { thread.setPriority(priority); } if (uncaughtExceptionHandler != null) { thread.setUncaughtExceptionHandler(uncaughtExceptionHandler); } return thread; } };
public Thread newThread(Runnable runnable) { Thread thread = new Thread(threadGroup, runnable,// threadGroup.getName() + "-" + namePrefix + "-" + threadNumber.getAndIncrement()); thread.setDaemon(daemon); if (thread.getPriority() != Thread.NORM_PRIORITY) { thread.setPriority(Thread.NORM_PRIORITY); } return thread; } }
@Override public Thread newThread(Runnable r) { Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); if (t.isDaemon()) t.setDaemon(false); t.setPriority(threadPriority); return t; } }
public Thread newThread(Runnable r) { Thread t = new Thread(group, r, name + "-" + threadNumber.getAndIncrement(), 0); t.setDaemon(daemon); if (t.getPriority() != Thread.NORM_PRIORITY) { t.setPriority(Thread.NORM_PRIORITY); } t.setUncaughtExceptionHandler(uncaughtExceptionHandler); return t; }
@Override public Thread newThread(Runnable r) { Thread thread = new Thread(threadGroup, r, namePrefix + currentThreadNumber.getAndIncrement(), 0); thread.setDaemon(isDaemon); thread.setPriority(priority); return thread; } }
/** * @param cleanerThread {@code true} if a thread should be started that removes stale entries. */ public WeakConcurrentMap(boolean cleanerThread) { target = new ConcurrentHashMap<WeakKey<K>, V>(); if (cleanerThread) { thread = new Thread(this); thread.setName("weak-ref-cleaner-" + ID.getAndIncrement()); thread.setPriority(Thread.MIN_PRIORITY); thread.setDaemon(true); thread.start(); } else { thread = null; } }
public Thread newThread(Runnable r) { Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); if (!t.isDaemon()) t.setDaemon(true); if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY); return t; } }
@Override public Thread newThread(Runnable r) { Thread t = new Thread(group, r, name + "-" + index.getAndIncrement(), 0); if (t.isDaemon()) { t.setDaemon(false); } if (t.getPriority() != Thread.NORM_PRIORITY) { t.setPriority(Thread.NORM_PRIORITY); } t.setUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER); return t; } }
@Override 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; } }
public Thread newThread(Runnable runnable) { Thread t = new Thread(group, runnable, name + "-" + index.getAndIncrement(), 0); if (t.isDaemon()) t.setDaemon(false); if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY); return t; } }
@Override public Thread newThread(Runnable r) { Thread t = newThread(FastThreadLocalRunnable.wrap(r), prefix + nextId.incrementAndGet()); try { if (t.isDaemon() != daemon) { t.setDaemon(daemon); } if (t.getPriority() != priority) { t.setPriority(priority); } } catch (Exception ignored) { // Doesn't matter even if failed to set. } return t; }
public static void check(final IUpdateCallback callback) { Runnable run = () -> { try { Release release = checkForNewRelease(); if (release != null) { callback.onUpdate(release); } } catch (Exception e) { LOG.debug("Jadx update error", e); } }; Thread thread = new Thread(run); thread.setName("Jadx update thread"); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); }
t.setPriority(priority); t.setDaemon(true); return t;
@Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setName(THREAD_NAME); thread.setPriority(THREAD_PRIORITY); thread.setDaemon(THREAD_DAEMON); thread.setUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER); return thread; } };
@Override public Thread newThread(Runnable r) { Thread t = newThread(FastThreadLocalRunnable.wrap(r), prefix + nextId.incrementAndGet()); try { if (t.isDaemon() != daemon) { t.setDaemon(daemon); } if (t.getPriority() != priority) { t.setPriority(priority); } } catch (Exception ignored) { // Doesn't matter even if failed to set. } return t; }
/** * Template method for the creation of a new {@link Thread}. * <p>The default implementation creates a new Thread for the given * {@link Runnable}, applying an appropriate thread name. * @param runnable the Runnable to execute * @see #nextThreadName() */ public Thread createThread(Runnable runnable) { Thread thread = new Thread(getThreadGroup(), runnable, nextThreadName()); thread.setPriority(getThreadPriority()); thread.setDaemon(isDaemon()); return thread; }
/** * Template method for the creation of a new {@link Thread}. * <p>The default implementation creates a new Thread for the given * {@link Runnable}, applying an appropriate thread name. * @param runnable the Runnable to execute * @see #nextThreadName() */ public Thread createThread(Runnable runnable) { Thread thread = new Thread(getThreadGroup(), runnable, nextThreadName()); thread.setPriority(getThreadPriority()); thread.setDaemon(isDaemon()); return thread; }
protected CentralJobScheduler() { workStealingExecutors = new ConcurrentHashMap<>( 1 ); topLevelGroup = new TopLevelGroup(); pools = new ThreadPoolManager( topLevelGroup ); ThreadFactory threadFactory = new GroupedDaemonThreadFactory( Group.TASK_SCHEDULER, topLevelGroup ); scheduler = new TimeBasedTaskScheduler( Clocks.nanoClock(), pools ); // The scheduler thread runs at slightly elevated priority for timeliness, and is started in init(). schedulerThread = threadFactory.newThread( scheduler ); int priority = Thread.NORM_PRIORITY + 1; schedulerThread.setPriority( priority ); }
/** * Tests whether the original priority is not changed if no priority is * specified. */ @Test public void testNewThreadNoPriority() { final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class); final Runnable r = EasyMock.createMock(Runnable.class); final int orgPriority = Thread.NORM_PRIORITY + 1; final Thread t = new Thread(); t.setPriority(orgPriority); EasyMock.expect(wrapped.newThread(r)).andReturn(t); EasyMock.replay(wrapped, r); final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build(); assertSame("Wrong thread", t, factory.newThread(r)); assertEquals("Wrong priority", orgPriority, t.getPriority()); EasyMock.verify(wrapped, r); }