[Bug 462098] Support setting ThreadGroup in ScheduledExecutorScheduler
Signed-off-by: John Gardiner Myers <jgmyers@proofpoint.com>
This commit is contained in:
parent
c8b84e0291
commit
a9be633816
15
jetty-util/src/main/java/org/eclipse/jetty/util/thread/ScheduledExecutorScheduler.java
Normal file → Executable file
15
jetty-util/src/main/java/org/eclipse/jetty/util/thread/ScheduledExecutorScheduler.java
Normal file → Executable file
|
@ -43,6 +43,7 @@ public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Sch
|
|||
private final String name;
|
||||
private final boolean daemon;
|
||||
private final ClassLoader classloader;
|
||||
private final ThreadGroup threadGroup;
|
||||
private volatile ScheduledThreadPoolExecutor scheduler;
|
||||
private volatile Thread thread;
|
||||
|
||||
|
@ -57,10 +58,16 @@ public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Sch
|
|||
}
|
||||
|
||||
public ScheduledExecutorScheduler(String name, boolean daemon, ClassLoader threadFactoryClassLoader)
|
||||
{
|
||||
this(name, daemon, threadFactoryClassLoader, null);
|
||||
}
|
||||
|
||||
public ScheduledExecutorScheduler(String name, boolean daemon, ClassLoader threadFactoryClassLoader, ThreadGroup threadGroup)
|
||||
{
|
||||
this.name = name == null ? "Scheduler-" + hashCode() : name;
|
||||
this.daemon = daemon;
|
||||
this.classloader = threadFactoryClassLoader;
|
||||
this.classloader = threadFactoryClassLoader == null ? Thread.currentThread().getContextClassLoader() : threadFactoryClassLoader;
|
||||
this.threadGroup = threadGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +78,7 @@ public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Sch
|
|||
@Override
|
||||
public Thread newThread(Runnable r)
|
||||
{
|
||||
Thread thread = ScheduledExecutorScheduler.this.thread = new Thread(r, name);
|
||||
Thread thread = ScheduledExecutorScheduler.this.thread = new Thread(threadGroup, r, name);
|
||||
thread.setDaemon(daemon);
|
||||
thread.setContextClassLoader(classloader);
|
||||
return thread;
|
||||
|
@ -123,11 +130,11 @@ public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Sch
|
|||
}
|
||||
}
|
||||
|
||||
private class ScheduledFutureTask implements Task
|
||||
private static class ScheduledFutureTask implements Task
|
||||
{
|
||||
private final ScheduledFuture<?> scheduledFuture;
|
||||
|
||||
public ScheduledFutureTask(ScheduledFuture<?> scheduledFuture)
|
||||
ScheduledFutureTask(ScheduledFuture<?> scheduledFuture)
|
||||
{
|
||||
this.scheduledFuture = scheduledFuture;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue