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 :
<property name="corePoolSize" value="500" /> <property name="maxPoolSize" value="1000" />
What is the difference between the two and will it scale. Currently I have approx. 10000 users.
Starting thread pool size is 1, core pool size is 5, max pool size is 10 and the queue is 100. As requests come in, threads will be created up to 5 and then tasks will be added to the queue until it reaches 100. When the queue is full new threads will be created up to maxPoolSize .
ThreadPoolTaskExecutor is a java bean that allows for configuring a ThreadPoolExecutor in a bean style by setting up the values for the instance variables like corePoolSize, maxPoolSize, keepAliveSeconds, queueCapacity and exposing it as a Spring TaskExecutor.
The default configuration is a core pool size of 1, with unlimited max pool size and unlimited queue capacity. This is roughly equivalent to Executors.
ThreadPoolExecutor is an ExecutorService to execute each submitted task using one of possibly several pooled threads, normally configured using Executors factory methods. It also provides various utility methods to check current threads statistics and control them.
Here are Sun’s rules for thread creation in simple terms:
corePoolSize
, create a new Thread to run a new task.corePoolSize
, put the task into the queue.maxPoolSize
, create a new thread to run tasks in.maxPoolSize
, reject the task.Full article
Origin answer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With