[Bug 462098] Support setting ThreadGroup in QueuedThreadPool

Signed-off-by: John Gardiner Myers <jgmyers@proofpoint.com>
This commit is contained in:
John Myers 2015-03-13 13:04:11 -07:00 committed by Greg Wilkins
parent c082848f93
commit c8b84e0291
1 changed files with 8 additions and 1 deletions

View File

@ -54,6 +54,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
private final ConcurrentLinkedQueue<Thread> _threads = new ConcurrentLinkedQueue<>();
private final Object _joinLock = new Object();
private final BlockingQueue<Runnable> _jobs;
private final ThreadGroup _threadGroup;
private String _name = "qtp" + hashCode();
private int _idleTimeout;
private int _maxThreads;
@ -83,6 +84,11 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
}
public QueuedThreadPool(@Name("maxThreads") int maxThreads, @Name("minThreads") int minThreads, @Name("idleTimeout") int idleTimeout, @Name("queue") BlockingQueue<Runnable> queue)
{
this(maxThreads, minThreads, idleTimeout, queue, null);
}
public QueuedThreadPool(@Name("maxThreads") int maxThreads, @Name("minThreads") int minThreads, @Name("idleTimeout") int idleTimeout, @Name("queue") BlockingQueue<Runnable> queue, @Name("threadGroup") ThreadGroup threadGroup)
{
setMinThreads(minThreads);
setMaxThreads(maxThreads);
@ -95,6 +101,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
queue=new BlockingArrayQueue<>(capacity, capacity);
}
_jobs=queue;
_threadGroup=threadGroup;
}
@Override
@ -461,7 +468,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
protected Thread newThread(Runnable runnable)
{
return new Thread(runnable);
return new Thread(_threadGroup, runnable);
}
@Override