To assign a task to ExecutorService, we can use the following methods-
execute(Runnable task)
submit(Runnable task) / submit(Callable
invokeAny(Collection> tasks)
invokeAll(Collection> tasks)
The Java ExecutorService's execute() method takes in a runnable object and performs its task asynchronously. After making the call to execute method, we call the shutdown method, which blocks any other task to queue up in the executorService.