I want to use a bounded queue for a ThreadPoolExecutor but I want to use my custom RejectedExecutionExceptionHandler. I would need to do that so that I can put rejected tasks to a separate queue and after a while try to resubmit them.
Is a custom RejectedExecutionExceptionHandler the solution to my problem? If yes how do I implement one?
Or else what would be the best way to deal with my issue?
I want to use a bounded queue for a ThreadPoolExecutor but I want to
Share
I would use an unbounded queue as this will queue tasks which cannot be run for later use. I would sue Executors.newFixedThreadPool in your case. You may be interested in what this does
Note: it uses an unbounded queue.
IMHO the simplest/best way to deal with the problem is to run the task in the current thread.
This ensures all tasks are performed in a timely manner using the current thread where there is no spare background threads.