RejectedExecutionHandler - ThreadPoolExecutor
Rivu Chakraborty
Mobile Leader | GDE (Google Dev Expert) for Android & Kotlin, India's first for Kotlin | Mobile Architect | Mobile Platform @ JioCinema / JioHotstar | Ex @ Meesho, Gojek, Paytm, BYJU'S | Tech Speaker | Author
While using I wanted to try to execute a rejected task once more. Is it really possible? I have heard of interface. There are many available(known) instances of the interface(RejectedExecutionHandler) such as ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy etc. but the problem is that they do not allow to retry the execution.
The only solution is to use custom RejectedExecutionHandler.
This article demonstrates how to do it: https://examples.javacodegeeks.com/core-java/util/concurrent/rejectedexecutionhandler/java-util-concurrent-rejectedexecutionhandler-example/
Happy Programming, Happy Learning
...................... :)