Class AdvancedThreadPoolService

    • Field Detail

      • executor

        protected java.util.concurrent.ExecutorService executor
        The executor service.
      • listeners

        protected java.util.List<IChangeListener<java.lang.Void>> listeners
        The finished listeners.
      • shutdown

        protected Future<java.lang.Void> shutdown
        Future for pool shutdown.
    • Constructor Detail

      • AdvancedThreadPoolService

        public AdvancedThreadPoolService​(IComponentIdentifier provider,
                                         boolean daemon)
        Create a new ThreadPool.
    • Method Detail

      • execute

        public void execute​(java.lang.Runnable task)
        Execute a task in its own thread.
        Specified by:
        execute in interface IThreadPool
        Parameters:
        task - The task to execute.
      • executeForever

        public void executeForever​(java.lang.Runnable task)
        Execute a task in its own thread. The pool expects the thread executing the task to never return. Preferably use this method if you want to permanently retrieve a thread e.g. for repeated blocking operations.
        Specified by:
        executeForever in interface IThreadPool
        Parameters:
        task - The task to execute.
      • shutdown

        public IFuture<java.lang.Void> shutdown()
        Service shutdown.
        Returns:
        Null, when done.
      • dispose

        public void dispose()
        Shutdown the thread pool.
        Specified by:
        dispose in interface IThreadPool
      • isRunning

        public boolean isRunning()
        Test if the thread pool is running.
        Specified by:
        isRunning in interface IThreadPool
      • notifyFinishListeners

        protected void notifyFinishListeners()
        Notify the finish listeners.
      • main

        public static void main​(java.lang.String[] args)
        Test main.