in src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java [181:208]
public ThreadPool create(ThreadPoolConfig config, String label) {
if ( config == null ) {
throw new IllegalArgumentException("Config must not be null.");
}
if ( label == null ) {
// generate the label by taking the first external frame off the stack trace
final StackTraceElement[] stackTrace = new Exception().getStackTrace();
if ( stackTrace != null && stackTrace.length > 1 ) {
if ( stackTrace[1].getClassName().equals( this.getClass().getName() ) ) {
label = stackTrace[2].getClassName();
} else {
label = stackTrace[1].getClassName();
}
}
}
final String name = "ThreadPool-" + UUID.randomUUID().toString() +
(label == null ? "" : " (" + label + ")");
final Entry entry = new Entry(null, config, name, bundleContext);
ThreadPool threadPool = null;
synchronized ( this.pools ) {
this.pools.put(name, entry);
threadPool = entry.incUsage();
}
entry.registerMBeanAndMetrics();
return threadPool;
}