Add thread groups
This commit is contained in:
parent
b9edef018a
commit
a412246212
@ -38,7 +38,7 @@ public class ShortNamedThreadFactory implements ThreadFactory {
|
||||
threadPoolNumber[i] = new AtomicInteger(1);
|
||||
}
|
||||
}
|
||||
private final ThreadGroup group;
|
||||
private ThreadGroup group;
|
||||
private final AtomicInteger threadNumber = new AtomicInteger(1);
|
||||
private static final String NAME_PATTERN = "%s-%d";
|
||||
private final String threadNamePrefix;
|
||||
@ -54,6 +54,11 @@ public class ShortNamedThreadFactory implements ThreadFactory {
|
||||
checkPrefix(threadNamePrefix), threadPoolNumber[(threadNamePrefix.hashCode() % POOL_NUMBERS_COUNT / 2) + POOL_NUMBERS_COUNT / 2].getAndIncrement());
|
||||
}
|
||||
|
||||
public ShortNamedThreadFactory withGroup(ThreadGroup threadGroup) {
|
||||
this.group = threadGroup;
|
||||
return this;
|
||||
}
|
||||
|
||||
private static String checkPrefix(String prefix) {
|
||||
return prefix == null || prefix.length() == 0 ? "Unnamed" : prefix;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user