/** * Provide a new ScheduledExecutorService instance. * * <p>A shutdown hook is created to terminate the thread pool on application termination. * * @return new ScheduledExecutorService */ public static ScheduledExecutorService defaultExecutorService() { ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(getCpuCount()); Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdown(scheduledExecutorService))); return scheduledExecutorService; }