Skip to content

Commit

Permalink
Fix | Changed executor thread to daemon so it doesn't prevent JVM fro…
Browse files Browse the repository at this point in the history
…m exiting (#944)

Changed a thread used to initialize ScheduledThreadPoolExecutor to daemon so the JVM can exit in specific bulkcopy scenarios.
  • Loading branch information
rene-ye committed Jan 25, 2019
1 parent 1d11613 commit 0702af9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/SharedTimer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ class SharedTimer implements Serializable {
private ScheduledThreadPoolExecutor executor;

private SharedTimer() {
executor = new ScheduledThreadPoolExecutor(1, task -> new Thread(task, CORE_THREAD_PREFIX + id));
executor = new ScheduledThreadPoolExecutor(1, task -> {
Thread t = new Thread(task, CORE_THREAD_PREFIX + id);
t.setDaemon(true);
return t;
});
executor.setRemoveOnCancelPolicy(true);
}

Expand Down

0 comments on commit 0702af9

Please sign in to comment.