A thread pool has been implemented in JAVA recently, mainly to complete a time-consuming task, which is described as follows:
In the thread, the task to be implemented may be a task that needs to run for more than 10 minutes, and several threads will be opened in each task. Considering the performance and stability of the server, control the total number of tasks.
The task is generated and started to run on the page. Considering the user's usage perception, you can display in real time how many tasks are running in the current background on the foreground. if the task is full, you can choose whether to add it to the execution waiting queue or discard the current task.
Therefore, this thread pool summarizes the following functions:
1. Execution queue Cache
2. task execution
3. you can obtain the current execution status, including the number of ongoing executions, the number of executions that can be added, the number of pending executions, and the execution percentage of each task, you can better decide whether to add the executable to the waiting queue when the number of executions is no longer available.
Do you have any suggestions for implementing such a thread pool?
This article is from "never stop !!!" Blog