Exercise – exploring Java executors
Objective: In this exercise, you will explore different types of executors provided by the Java Concurrency API. You will refer to the Java documentation, use a different executor implementation, and observe its behavior in a sample program.
Instructions:
- Visit the Java documentation for the
Executors
class: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html. - Read through the documentation and familiarize yourself with the different factory methods provided by the
Executors
class for creatingExecutor
instances. - Choose a different executor implementation other than the fixed thread pool used in the previous examples. Some options include the following:
Executors.newCachedThreadPool()
Executors.newSingleThreadExecutor()
Executors.newScheduledThreadPool(int corePoolSize)
- Create a new Java class called
ExecutorExploration
and replace the Executor creation line with the chosen executor implementation...