Will ThreadPoolExecutor.CallerRunsPolicy ever throw a RejectedExecutionException?

Are there any circumstances under which ThreadPoolExecutor.CallerRunsPolicy will raise a RejectedExecutionException ?

It seems to me that the policy itself is designed to prevent the release of these Exceptions. The API for its RejectedExecutionHandler.rejectedExecution () interface method claims that it can throw a RejectedExecutionException . The API for CallerRunsPolicy.rejectedExecution () does not work.

Summary: Do I need to explicitly handle a RejectedExecutionException on execute() if I use CallerRunsPolicy ?

+4
source share
1 answer

No no. ThreadPoolExecutor.CallerRunsPolicy will never throw a RejectedExecutionException unless you explicitly throw it under Runnable#run

+4
source

All Articles