isShutdown() and isTerminated() Status Methods
You'll learn: How to distinguish between an executor that's begun shutting down versus one that has completely finished all work.
Understanding Executor States
An executor can exist in three distinct states:
- Running - Accepting new tasks and processing them
- Shutdown initiated - No longer accepting new tasks, but still processing existing ones
- Fully terminated - All tasks completed, no threads active
Think of a restaurant closing for the night: "shutdown initiated" means the doors are locked and no new customers are seated, but the kitchen is still finishing orders for people already inside. "Fully terminated" means everyone has left and the lights are off.
The Two Status Methods
isShutdown()
Returns true if shutdown() or shutdownNow() has been called, regardless of whether tasks are still running. This simply tells you "have we started the shutdown process?"
ExecutorService executor = Executors.newFixedThreadPool(2);
System.out.println(executor.isShutdown()); // false
executor.shutdown();
System.out.println(executor.isShutdown()); // true immediately
isTerminated()
Returns true only when the executor has completely finished: shutdown was initiated and all tasks have completed. No threads are running anymore.
executor.shutdown();
System.out.println(executor.isTerminated()); // likely false (tasks still running)
executor.awaitTermination(1, TimeUnit.MINUTES);
System.out.println(executor.isTerminated()); // true if all finished
Why Both Matter
You need both methods because they answer different questions. isShutdown() tells you if the executor will reject new tasks. isTerminated() tells you if all work is truly done and resources are freed.
Key Takeaway: isShutdown() becomes true immediately when shutdown begins; isTerminated() only becomes true after all tasks complete and all threads stop.