1414import java .util .Date ;
1515import java .util .Set ;
1616import java .util .concurrent .ExecutorService ;
17+ import java .util .concurrent .Executors ;
1718import java .util .concurrent .LinkedBlockingQueue ;
1819import java .util .concurrent .RejectedExecutionHandler ;
1920import java .util .concurrent .ScheduledThreadPoolExecutor ;
21+ import java .util .concurrent .ThreadFactory ;
2022import java .util .concurrent .ThreadPoolExecutor ;
2123import java .util .concurrent .TimeUnit ;
2224
@@ -26,12 +28,21 @@ public class Bugsnag {
2628 private static final int SESSION_TRACKING_PERIOD_MS = 60000 ;
2729 private static final int CORE_POOL_SIZE = 1 ;
2830
31+ private final ThreadFactory sessionThreadFactory = new ThreadFactory () {
32+ @ Override
33+ public Thread newThread (Runnable runnable ) {
34+ Thread thread = Executors .defaultThreadFactory ().newThread (runnable );
35+ thread .setName ("bugsnag-sessions-" + thread .getId ());
36+ return thread ;
37+ }
38+ };
2939 // Create an executor service which keeps idle threads alive for a maximum of SHUTDOWN_TIMEOUT.
3040 // This should avoid blocking an application that doesn't call shutdown from exiting.
3141 private ExecutorService sessionFlusherService =
3242 new ThreadPoolExecutor (0 , 1 ,
3343 SHUTDOWN_TIMEOUT_MS , TimeUnit .MILLISECONDS ,
34- new LinkedBlockingQueue <Runnable >());
44+ new LinkedBlockingQueue <Runnable >(),
45+ sessionThreadFactory );
3546
3647 private ScheduledThreadPoolExecutor sessionExecutorService =
3748 new ScheduledThreadPoolExecutor (CORE_POOL_SIZE ,
0 commit comments