Multi-thread (four) the work process of the thread pool

When executing execute() to add tasks:
1. The current number of threads is less than the number of core threads, and threads are created and run immediately. Otherwise, enter the blocking queue and wait.
2. If the queue is full, non-core threads will be created and executed immediately. (Note that tasks in the blocking queue are still waiting at this time).
        If there are more tasks coming in, and the number of running threads is greater than or equal to the maximum number of threads at this time, the saturation rejection strategy is started.
3. When the task execution in the thread is completed, the task is fetched from the queue.
4. If a thread is idle, it will judge whether it is greater than the number of core threads according to the idle time, and if it is greater than that, it will destroy the thread and release the memory.

Guess you like

Origin blog.csdn.net/x18094/article/details/114993793