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

后端 未结 6 1721
一个人的身影
一个人的身影 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:43

    What everyone has explained so clearly is correct. Few things to notice here is that you should always have a limited size for core-pool as well as queue. If the core-pool-size if very high, there can a high chance that many of your threads from pool are remaining unused for certain period of time since for every request new thread gets created until it reaches max-pool-size

    But if your machine is going to face large number of request concurrently then you should also consider that the machine size is sufficient enough : example:

    If your machine size in 1 GB and queue capacity is at Integer.MAX_VALUE then there is a high chance that your machine will start rejecting the requesting at some point of time because of OutOfMemory which you can monitor in any JVM GUI tool.

提交回复
热议问题