I have an ExecutorService which executes tasks which itself submit new tasks to the ExecutorService.
When I call .shutdown(), I want the running tasks still being able to submit new tasks to the ExecutorService which need to be finished. But I don’t want to be able to submit new tasks from outside to the ExecutorService.
How can I still allow tasks to submit subtasks when the ExecutorService is shutting down?
After you called shutdown, you shouldn’t submit any new tasks, it’s against the logic.
Use a different executor service for the inner tasks. Or create an executor for yourself (that wraps or extends an executor of your choice) that is capable of checking the submitter and based on its state it either allows or not allows the task submission.