ThreadPoolExecutor+BlockingQueue executes time-consuming tasks, threads in the thread pool can be reused, and tasks that exceed the maximumPoolSize of the thread pool can wait in the blocking queue BlockingQueue.
The task should be a task of synchronous operation, so that there will be blocking and will not be swarmed.
If it is a time-consuming task and it is an asynchronous task, then there is no blocking, it will be executed in an instant (the threads of the thread pool have been reused), and all tasks will run, but the time-consuming operations of the previous tasks are not completed in an instant. , causing subsequent task timeouts or other problems.
ThreadPoolExecutor+BlockingQueue needs to pay attention to the execution of time-consuming tasks
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325340757&siteId=291194637
Ranking