public static ScheduledExecutorService newScheduledDaemonThreadPool ( int corePoolSize ) { return Executors . newScheduledThreadPool ( corePoolSize , r -> { Thread t = Executors . defaultThreadFactory ( ) . newThread ( r ) ; t . setDaemon ( true ) ; return t ; } ) ; }
Creates a scheduled thread pool where each thread has the daemon property set to true . This allows the program to quit without explicitly calling shutdown on the pool