@ NotNull static ExecutorService newExecutor ( ) { ThreadPoolExecutor tpe = new ThreadPoolExecutor ( 0 , 1 , 10 , TimeUnit . SECONDS , new SynchronousQueue < Runnable > ( ) ) ; tpe . allowCoreThreadTimeOut ( true ) ; return tpe ; }
Creates an executor service with one thread that is removed automatically after 10 second idle time . The pool is therefore garbage collected and shutdown automatically .