Skip to content

Commit

Permalink
[GR-8492] ThreadFactory implemented to mark threads as daemon.
Browse files Browse the repository at this point in the history
  • Loading branch information
entlicher committed Feb 28, 2018
1 parent 91bd3ae commit 7ec916e
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.concurrent.Phaser;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -596,7 +597,7 @@ private CharSequence getSourceMapURL(Source source, int lastLine) {

private class SuspendedCallbackImpl implements SuspendedCallback {

private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, new SchedulerThreadFactory());
private final AtomicReference<ScheduledFuture<?>> future = new AtomicReference<>();
private Thread locked = null;

Expand Down Expand Up @@ -715,6 +716,24 @@ private synchronized void unlock() {
locked = null;
notify();
}

private class SchedulerThreadFactory implements ThreadFactory {

private final ThreadGroup group;

SchedulerThreadFactory() {
SecurityManager s = System.getSecurityManager();
this.group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
}

@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(group, r, "Suspend Unlocking Scheduler");
t.setDaemon(true);
t.setPriority(Thread.NORM_PRIORITY);
return t;
}
}
}

private static JSONArray getFramesParam(CallFrame[] callFrames) {
Expand Down

0 comments on commit 7ec916e

Please sign in to comment.