return new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
final MemoryManager mm = config.getMemoryManager();
final ThreadLocalPoolProvider threadLocalPoolProvider;
if (mm instanceof ThreadLocalPoolProvider) {
threadLocalPoolProvider = (ThreadLocalPoolProvider) mm;
} else {
threadLocalPoolProvider = null;
}
final DefaultWorkerThread thread =
new DefaultWorkerThread(Grizzly.DEFAULT_ATTRIBUTE_BUILDER,
config.getPoolName() + '(' + counter.incrementAndGet() + ')',
((threadLocalPoolProvider != null) ? threadLocalPoolProvider.createThreadLocalPool() : null),
r);
thread.setUncaughtExceptionHandler(AbstractThreadPool.this);
thread.setPriority(config.getPriority());
thread.setDaemon(config.isDaemon());