What is the difference between corePoolSize and maxPoolSize in the Spring ThreadPoolTaskExecutor

后端 未结 6 1741
一个人的身影
一个人的身影 2020-12-08 04:17

I have to send out massEmails to all users of a website. I want to use a thread pool for each email that is sent out. Currently I have set the values to :

&l         


        
6条回答
  •  清歌不尽
    2020-12-08 04:53

    Here are Sun’s rules for thread creation in simple terms:

    1. If the number of threads is less than the corePoolSize, create a new Thread to run a new task.
    2. If the number of threads is equal (or greater than) the corePoolSize, put the task into the queue.
    3. If the queue is full, and the number of threads is less than the maxPoolSize, create a new thread to run tasks in.
    4. If the queue is full, and the number of threads is greater than or equal to maxPoolSize, reject the task.

    Full article

    Origin answer

提交回复
热议问题