DefaultThreadFactory Class — netty Architecture
Architecture documentation for the DefaultThreadFactory class in DefaultThreadFactory.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5812a65b_3170_78e7_d113_0fe81ef5c6b0["DefaultThreadFactory"] fc22cc7f_d2a5_706d_e2bc_0fd5ce29321b["DefaultThreadFactory.java"] 5812a65b_3170_78e7_d113_0fe81ef5c6b0 -->|defined in| fc22cc7f_d2a5_706d_e2bc_0fd5ce29321b 1fe376e0_cc95_3214_32a0_fb41c4bdc581["DefaultThreadFactory()"] 5812a65b_3170_78e7_d113_0fe81ef5c6b0 -->|method| 1fe376e0_cc95_3214_32a0_fb41c4bdc581 fba20832_3ce0_dfd0_4ce7_9ec47c7f0d6f["String()"] 5812a65b_3170_78e7_d113_0fe81ef5c6b0 -->|method| fba20832_3ce0_dfd0_4ce7_9ec47c7f0d6f 643df49a_afd5_45fc_a0cb_27f56e660ea2["Thread()"] 5812a65b_3170_78e7_d113_0fe81ef5c6b0 -->|method| 643df49a_afd5_45fc_a0cb_27f56e660ea2
Relationship Graph
Source Code
common/src/main/java/io/netty/util/concurrent/DefaultThreadFactory.java lines 29–123
public class DefaultThreadFactory implements ThreadFactory {
private static final AtomicInteger poolId = new AtomicInteger();
private final AtomicInteger nextId = new AtomicInteger();
private final String prefix;
private final boolean daemon;
private final int priority;
protected final ThreadGroup threadGroup;
public DefaultThreadFactory(Class<?> poolType) {
this(poolType, false, Thread.NORM_PRIORITY);
}
public DefaultThreadFactory(String poolName) {
this(poolName, false, Thread.NORM_PRIORITY);
}
public DefaultThreadFactory(Class<?> poolType, boolean daemon) {
this(poolType, daemon, Thread.NORM_PRIORITY);
}
public DefaultThreadFactory(String poolName, boolean daemon) {
this(poolName, daemon, Thread.NORM_PRIORITY);
}
public DefaultThreadFactory(Class<?> poolType, int priority) {
this(poolType, false, priority);
}
public DefaultThreadFactory(String poolName, int priority) {
this(poolName, false, priority);
}
public DefaultThreadFactory(Class<?> poolType, boolean daemon, int priority) {
this(toPoolName(poolType), daemon, priority);
}
public static String toPoolName(Class<?> poolType) {
ObjectUtil.checkNotNull(poolType, "poolType");
String poolName = StringUtil.simpleClassName(poolType);
switch (poolName.length()) {
case 0:
return "unknown";
case 1:
return poolName.toLowerCase(Locale.US);
default:
if (Character.isUpperCase(poolName.charAt(0)) && Character.isLowerCase(poolName.charAt(1))) {
return Character.toLowerCase(poolName.charAt(0)) + poolName.substring(1);
} else {
return poolName;
}
}
}
public DefaultThreadFactory(String poolName, boolean daemon, int priority, ThreadGroup threadGroup) {
ObjectUtil.checkNotNull(poolName, "poolName");
if (priority < Thread.MIN_PRIORITY || priority > Thread.MAX_PRIORITY) {
throw new IllegalArgumentException(
"priority: " + priority + " (expected: Thread.MIN_PRIORITY <= priority <= Thread.MAX_PRIORITY)");
}
prefix = poolName + '-' + poolId.incrementAndGet() + '-';
this.daemon = daemon;
this.priority = priority;
this.threadGroup = threadGroup;
}
public DefaultThreadFactory(String poolName, boolean daemon, int priority) {
this(poolName, daemon, priority, null);
}
@Override
public Thread newThread(Runnable r) {
Thread t = newThread(FastThreadLocalRunnable.wrap(r), prefix + nextId.incrementAndGet());
try {
if (t.isDaemon() != daemon) {
t.setDaemon(daemon);
}
Source
Frequently Asked Questions
What is the DefaultThreadFactory class?
DefaultThreadFactory is a class in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/DefaultThreadFactory.java.
Where is DefaultThreadFactory defined?
DefaultThreadFactory is defined in common/src/main/java/io/netty/util/concurrent/DefaultThreadFactory.java at line 29.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free