-
Bug
-
Resolution: Fixed
-
P3
-
6
-
b81
-
x86
-
linux_redhat_9.0
-
Verified
If you create a singlethreaded executor, submit a single task into it and forget its reference, both the ThreadPoolExecutor and its associated Thread will stay alive forever although there is an obvious attempt at shutting down the thread in such case (ThreadPoolExecutor's finalizer)
While ThreadPoolExecutor.finalize() calls the shutdown() method which should tear down the waiting threads, this never happens, as the threads keep reference to the TPE instance on the stack ("this"). This causes a leak.
While we have found this problem through a bug on our side (which we already fixed), I still believe this is actual bug and the scenario with creating executors and forgetting about them should be supported.
While ThreadPoolExecutor.finalize() calls the shutdown() method which should tear down the waiting threads, this never happens, as the threads keep reference to the TPE instance on the stack ("this"). This causes a leak.
While we have found this problem through a bug on our side (which we already fixed), I still believe this is actual bug and the scenario with creating executors and forgetting about them should be supported.
- relates to
-
JDK-8145304 Executors.newSingleThreadExecutor().submit(runnable) throws RejectedExecutionException
- Open
-
JDK-8302899 Executors.newSingleThreadExecutor can use Cleaner to shutdown executor
- Resolved