Class Executors


  • public class Executors
    extends Object
    Factory and utility methods to for the Executor framework.
    Author:
    carcassi
    • Constructor Detail

      • Executors

        public Executors()
    • Method Detail

      • swingEDT

        public static Executor swingEDT()
        Executes tasks on the Swing Event Dispatch Thread using SwingUtilities.invokeLater().
        Returns:
        an executor that posts events on the EDT
      • localThread

        public static Executor localThread()
        Executes tasks on the current thread.
        Returns:
        an object that runs tasks on the current thread
      • namedPool

        public static ThreadFactory namedPool​(String poolName)
        A thread factory where each new thread starts with the given name. The name of the thread will be poolname + number. This can be used instead of Executors.defaultThreadFactory(), which unfortunately only use generic names for the thread, which makes it harder to debug.
        Parameters:
        poolName - name of the pool
        Returns:
        a new factory