Class MoreExecutors.DirectExecutorService

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Object lock
      Lock used whenever accessing the state variables (runningTasks, shutdown) of the executor
      private int runningTasks  
      private boolean shutdown  
    • Field Detail

      • lock

        private final java.lang.Object lock
        Lock used whenever accessing the state variables (runningTasks, shutdown) of the executor
      • runningTasks

        private int runningTasks
      • shutdown

        private boolean shutdown
    • Constructor Detail

      • DirectExecutorService

        private DirectExecutorService()
    • Method Detail

      • execute

        public void execute​(java.lang.Runnable command)
      • isShutdown

        public boolean isShutdown()
      • shutdown

        public void shutdown()
      • shutdownNow

        public java.util.List<java.lang.Runnable> shutdownNow()
      • isTerminated

        public boolean isTerminated()
      • awaitTermination

        public boolean awaitTermination​(long timeout,
                                        java.util.concurrent.TimeUnit unit)
                                 throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • startTask

        private void startTask()
        Checks if the executor has been shut down and increments the running task count.
        Throws:
        java.util.concurrent.RejectedExecutionException - if the executor has been previously shutdown
      • endTask

        private void endTask()
        Decrements the running task count.