Submitting to an Executor from a running task

前端 未结 3 1243
执念已碎
执念已碎 2021-01-17 02:03

Is it safe for a task (a Runnable) being run by an Executor to submit (execute()) a task? Can it result in deadlock, if using any of the standard Java executors

3条回答
  •  旧巷少年郎
    2021-01-17 02:58

    If there is a deadlock, it will be created by conditions in your deployed runnables. The ExecutorService itself is just a reusable thread pool. It handles queueing runnables for execution. There should be no reason the ExecutorService itself would be deadlocked regardless of where the Runnables originated from.

提交回复
热议问题