Using Thread Pools

suggest change

Thread Pools are used mostly calling methods in ExecutorService.

The following methods can be used to submit work for execution:

Method Description
submit Executes a the submitted work and return a future which can be used to get the result
execute Execute the task sometime in the future without getting any return value
invokeAll Execute a list of tasks and return a list of Futures
invokeAny Executes all the but return only the result of one that has been successful (without exceptions)

Once you are done with the Thread Pool you can call shutdown() to terminate the Thread Pool. This executes all pending tasks. To wait for all tasks to execute you can can loop around awaitTermination or isShutdown().

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents