Overview
As a thread pool, the executor service can not only improve the efficiency of performing tasks, but also control a set of related tasks. For example, you can use the Shutdownnow method in the executor to cancel all tasks. Control Task Group
java.util.concurrent.executorservice T invokeany (collection<callable<t>> Tasks) T Invokeany (collection<callable<t>> tasks, long timeout,timeunit unit)//Perform a given task,
Returns the result of one of the tasks (any completed results of the program). The second method, if a timeout occurs, throws a TimeoutException exception list<future<t>> InvokeAll (collection<callable<t>> Tasks) list<future<t>> InvokeAll (collection<callable<t>> tasks,long timeout, TimeUnit unit) /perform the given task and return all the results.
The second method throws a timeout exception exception if a timeout occurs java.util.concurrent.executorcompletionservice<v> Executorcompletionservice (Executor E)//build an executor to complete the service to collect the results of a given executor future<v> submit (callable<v> Task) Future <V> Submit (Runnable task,v Results)//Submit a task to the underlying executor future<v> take ()//Remove the next completed result, blocking Future if no completed results are available <V> poll () future<v> poll (long time,timeunit unit)//Remove the next completed result and return NULL if no completed results are available. The second method waits for a given time.
PS: Where InvokeAll has a special place: if it creates 3 tasks, he will create a new 2 child threads, and the remaining tasks will continue to execute on this thread.