Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8248381: Create a daemon thread for MonocleTimer
Reviewed-by: kcr, jvos
  • Loading branch information
jgneff authored and kevinrushforth committed Jul 21, 2020
1 parent 2f4666a commit 5f60ea5
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -34,6 +34,8 @@
* Monocle implementation class for Timer.
*/
final class MonocleTimer extends Timer {
private static final String THREAD_NAME = "Monocle Timer";

private static ScheduledThreadPoolExecutor scheduler;
private ScheduledFuture<?> task;

Expand All @@ -51,7 +53,11 @@ static int getMaxPeriod_impl() {

@Override protected long _start(final Runnable runnable, int period) {
if (scheduler == null) {
scheduler = new ScheduledThreadPoolExecutor(1);
scheduler = new ScheduledThreadPoolExecutor(1, target -> {
Thread thread = new Thread(target, THREAD_NAME);
thread.setDaemon(true);
return thread;
});
}

task = scheduler.scheduleAtFixedRate(runnable, 0, period, TimeUnit.MILLISECONDS);
Expand Down

0 comments on commit 5f60ea5

Please sign in to comment.