How it works...

In this recipe, you implemented a task that blocks its execution thread for a random number of milliseconds. Then, you sent 10 tasks to an executor, and while you were waiting for their finalization, you wrote information about the status of the executor to the console. You used the following methods to get the status of the Executor object:

  • getCorePoolSize(): This method returns an int number, which refers to the core number of threads. It's the minimum number of threads that will be in the internal thread pool when the executor is not executing any task.
  • getPoolSize(): This method returns an int value, which refers to the actual size of the internal thread pool.
  • getActiveCount(): This method returns an int number, which refers to the number of threads that are currently executing tasks.
  • getTaskCount(): This method returns a long number, which refers to the number of tasks that have been scheduled for execution.
  • getCompletedTaskCount(): This method returns a long number, which refers to the number of tasks that have been executed by this executor and have finished their execution.
  • isShutdown(): This method returns a Boolean value when the shutdown() method of an executor is called to finish its execution.
  • isTerminating(): This method returns a Boolean value when the executor performs the shutdown() operation but hasn't finished it yet.
  • isTerminated(): This method returns a Boolean value when the executor finishes its execution.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.99.174