In the case of a multithreading-limited configuration where the amount of emails being sent does not divide evenly by the number of threads specified, the program spawns an additional thread to send the remainder of the emails. This behavior can be summarized as follows:
Num. emails = 100
Num. threads = 14
The worker thread manager divides 100 // 14 and gets 7 emails per thread. It then detects that since 7*14 = 98, it will be short 2 emails of the desired 100. Therefore, it elects to spawn a 15th thread to send the remaining 2 emails:
This behavior should be replaced by instead increasing slightly the workload for 2 of the 14 preexisting threads, such that the number of emails sent by each thread will be as follows:
In the case of a multithreading-limited configuration where the amount of emails being sent does not divide evenly by the number of threads specified, the program spawns an additional thread to send the remainder of the emails. This behavior can be summarized as follows:
The worker thread manager divides
100 // 14
and gets7
emails per thread. It then detects that since7*14 = 98
, it will be short2
emails of the desired100
. Therefore, it elects to spawn a 15th thread to send the remaining2
emails:This behavior should be replaced by instead increasing slightly the workload for 2 of the 14 preexisting threads, such that the number of emails sent by each thread will be as follows:
so that the total number of emails equals 100 and the total number of threads equals 14.