public NamedThreadFactory(String prefix, boolean daemon) { mPrefix = prefix + "-thread-"; mDaemon = daemon; SecurityManager s = System.getSecurityManager(); mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup(); }
public NamedThreadFactory(String prefix, boolean daemon) { mPrefix = prefix + "-thread-"; mDaemon = daemon; SecurityManager s = System.getSecurityManager(); mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup(); }
public DefaultThreadFactory(String poolName, boolean daemon, int priority) { this(poolName, daemon, priority, System.getSecurityManager() == null ? Thread.currentThread().getThreadGroup() : System.getSecurityManager().getThreadGroup()); }
DefaultThreadFactory(int threadPriority, String threadNamePrefix) { this.threadPriority = threadPriority; group = Thread.currentThread().getThreadGroup(); namePrefix = threadNamePrefix + poolNumber.getAndIncrement() + "-thread-"; }
private ThreadSorterBase() { ThreadGroup tg = Thread.currentThread().getThreadGroup(); while (tg.getParent() != null) tg = tg.getParent(); Thread[] threads = new Thread[tg.activeCount()*2]; int threadsLen = tg.enumerate(threads, true); for (int i = 0; i < threadsLen; i++) { ThreadGroup group = threads[i].getThreadGroup(); map.put(threads[i].getId(), group != null ? group.getName() : null); } }
public NamedThreadFactory(String name, boolean daemon){ this.name = name; this.daemon = daemon; SecurityManager s = System.getSecurityManager(); group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); }
/** * Return the system thread group (sometimes also referred as "root thread group"). * * @return the system thread group * @throws SecurityException if the current thread cannot modify * thread groups from this thread's thread group up to the system thread group */ public static ThreadGroup getSystemThreadGroup() { ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); while(threadGroup.getParent() != null) { threadGroup = threadGroup.getParent(); } return threadGroup; }
public NettyRenameThreadFactory(String name) { SecurityManager s = System.getSecurityManager(); group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); this.name = name; }
private NamedThreadFactory(String name) { final SecurityManager s = System.getSecurityManager(); this.group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); this.namePrefix = name; }
public DefaultThreadFactory(String poolName, boolean daemon, int priority) { this(poolName, daemon, priority, System.getSecurityManager() == null ? Thread.currentThread().getThreadGroup() : System.getSecurityManager().getThreadGroup()); }
public NamedThreadFactory(String namePrefix, boolean daemon) { this.daemon = daemon; SecurityManager s = System.getSecurityManager(); group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); this.namePrefix = namePrefix; }
@Deprecated public NamedThreadFactory( String threadNamePrefix, int priority, Monitor monitor, boolean daemon ) { this.threadNamePrefix = threadNamePrefix; SecurityManager securityManager = System.getSecurityManager(); group = (securityManager != null) ? securityManager.getThreadGroup() : Thread.currentThread().getThreadGroup(); this.priority = priority; this.daemon = daemon; this.monitor = monitor; }
DaemonThreadFactory(String name, int firstThreadNum) { threadNumber.set(firstThreadNum); SecurityManager s = System.getSecurityManager(); group = (s != null)? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); namePrefix = name + "-"; }
public NamedThreadFactory(String prefix, boolean daemo) { mPrefix = prefix + "-thread-"; mDaemo = daemo; SecurityManager s = System.getSecurityManager(); mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup(); }
public NamedThreadFactory(String prefix, boolean daemo) { mPrefix = prefix + "-thread-"; mDaemo = daemo; SecurityManager s = System.getSecurityManager(); mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup(); }
NettyRenameThreadFactory(String name) { SecurityManager s = System.getSecurityManager(); group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); this.name = name; }
public DefaultThreadFactory(String prefix, boolean isDaemon, int priority) { SecurityManager s = System.getSecurityManager(); this.threadGroup = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); this.namePrefix = prefix + "-" + poolNumber.getAndIncrement() + "-thread-"; this.isDaemon = isDaemon; this.priority = priority; }
public NamedThreadFactory(String prefix, boolean daemo) { mPrefix = prefix + "-thread-"; mDaemo = daemo; SecurityManager s = System.getSecurityManager(); mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup(); }
public static void logTrace( int skip, int limit, String fmt, Object... args ) { if ( enabledAssertions() ) { Thread thread = Thread.currentThread(); String threadName = thread.getName(); ThreadGroup group = thread.getThreadGroup(); String groupPart = group != null ? " in group " + group.getName() : ""; String message = "[" + threadName + groupPart + "] " + String.format( fmt, args ); TraceLog traceLog = new TraceLog( message ); printLimitedStackTrace( System.err, traceLog, skip, limit ); } }
public void testThreadFactoryBuilder_defaults() throws InterruptedException { ThreadFactory threadFactory = builder.build(); Thread thread = threadFactory.newThread(monitoredRunnable); checkThreadPoolName(thread, 1); Thread defaultThread = Executors.defaultThreadFactory().newThread(monitoredRunnable); assertEquals(defaultThread.isDaemon(), thread.isDaemon()); assertEquals(defaultThread.getPriority(), thread.getPriority()); assertSame(defaultThread.getThreadGroup(), thread.getThreadGroup()); assertSame(defaultThread.getUncaughtExceptionHandler(), thread.getUncaughtExceptionHandler()); assertFalse(completed); thread.start(); thread.join(); assertTrue(completed); // Creating a new thread from the same ThreadFactory will have the same // pool ID but a thread ID of 2. Thread thread2 = threadFactory.newThread(monitoredRunnable); checkThreadPoolName(thread2, 2); assertEquals( thread.getName().substring(0, thread.getName().lastIndexOf('-')), thread2.getName().substring(0, thread.getName().lastIndexOf('-'))); // Building again should give us a different pool ID. ThreadFactory threadFactory2 = builder.build(); Thread thread3 = threadFactory2.newThread(monitoredRunnable); checkThreadPoolName(thread3, 1); assertThat(thread2.getName().substring(0, thread.getName().lastIndexOf('-'))) .isNotEqualTo(thread3.getName().substring(0, thread.getName().lastIndexOf('-'))); }