JAVAWarningRuntime ErrorMay 9, 2026

Runtime Error

java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ThreadPoolExecutor$Worker@34a1d7a6 rejected from java.util.concurrent.ThreadPoolExecutor@3c6b1b4e[Shutting down, pool size = 1, active threads = 0, queued tasks = 0, completed tasks = 1]

What This Error Means

This error occurs when a task is submitted to an executor service that is shutting down or has been terminated.

Why It Happens

This error typically happens when you are trying to execute a task in a thread pool that has already been shut down or terminated. This can be caused by a race condition where the task is submitted after the executor has been shut down, or it can be caused by a logical error where the task is not properly checking if the executor is still active before submitting it.

How to Fix It

  1. 1To fix this error, you need to ensure that you are not submitting tasks to a shut down executor service. You can achieve this by checking if the executor is still active before submitting the task, or by using a try-catch block to catch this exception and handle it accordingly. If you need to shut down the executor service, make sure to await its termination using the awaitTermination() method before shutting it down.

Example Code Solution

❌ Before (problematic code)
Java
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.shutdownNow();
executor.execute(new MyTask());
✅ After (fixed code)
Java
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.shutdown();
try {
  executor.awaitTermination(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
  Thread.currentThread().interrupt();
}
executor.execute(new MyTask());

Fix for java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ThreadPoolExecutor$Worker@34a1d7a6 rejected from java.util.concurrent.ThreadPoolExecutor@3c6b1b4e[Shutting down, pool size = 1, active threads = 0, queued tasks = 0, completed tasks = 1]

Related JAVA Errors

Related JAVA Blog Articles

Have a different error? Get an instant explanation.

Explain Another Error