Card 09/ 09
All 9 cards
RecapDifficulty: Advanced1 min
Submit, Wait, Shut Down
Five things this topic established, and where each one was.
| The thing | Where |
|---|---|
| A pool separates what work there is from which thread runs it | Handing Work to a Pool |
Callable returns a value and may throw; Runnable does neither | Runnable Against Callable |
get() blocks, so submit everything before collecting anything | What Future.get() Does |
shutdown asks, awaitTermination waits, shutdownNow insists | Shutting a Pool Down |
| A pool nobody shuts down keeps the process alive with nothing to do | Why Your Program Hung After main Returned |
The one worth carrying: submitting is not running and getting is waiting. Almost every disappointing result from a thread pool is one of those two sentences being forgotten at a call site.