Class ExecutorServiceUtils


  • public class ExecutorServiceUtils
    extends Object
    • Constructor Detail

      • ExecutorServiceUtils

        public ExecutorServiceUtils()
    • Method Detail

      • newBlockingThreadPoolExecutor

        public static ExecutorService newBlockingThreadPoolExecutor()
        Create a default thread pool executor with twice as many threads as there are processors reported by the JVM (assumes hyperthreading), and allowing a queue size of 10 per thread.
        Returns:
      • newBlockingThreadPoolExecutor

        public static ExecutorService newBlockingThreadPoolExecutor​(int threads,
                                                                    int queueSize)
        A util method from stack overflow (link?) to avoid unbounding queuing of tasks Submitting a task to an executor when its queue is full will block.