What is the best processing method RejectedExecutionExceptionwhen used ThreadPoolExecutorin Java?
I want to make sure that the task should not be missed and must be carried out. At the moment, there are no strict requirements for real time to complete the task.
One of the things that I thought could be done was to wait in a loop until I know that there is a space in the runnable queue, then go ahead and add it to the queue.
I would be glad if people can share their experiences.
Adding a possible solution, although I:
while(executor.getQueue().remainingCapacity <= 0){
Thread.sleep(100);
};
executor.execute(new ThreadInstance(params));
source
share