Card 09/ 09

RecapDifficulty: Advanced1 min

Recap: Executors and Futures

Pools, the two task types, blocking get, shutdown, and the pool that keeps a process alive.

Executors and futures come down to the five ideas below, each listed with the card that covers it.

What the topic established, and which card it was on
The ideaWhere
A pool separates what work there is from which thread runs itThread Pools: Handing Work to a Fixed Set of Threads
Callable returns a value and may throw; Runnable does neitherRunnable vs Callable
get() blocks, so submit everything before collecting anythingFuture.get(): Why Calling It Too Early Removes the Overlap
shutdown asks, awaitTermination waits, shutdownNow insistsShutting Down an ExecutorService Without Losing Work
A pool nobody shuts down keeps the process alive with nothing to doUnclosed Thread Pools: Why a Program Hangs After main Returns

Submitting is not running, and getting is waiting. Almost every disappointing result from a thread pool is one of those two facts forgotten at a call site.