java - Why does ScheduledThreadPoolExecutor only accept a fixed number of threads? -


I can think that some tasks are set for a very long time and Scheduled ThreadPoolExecutor Threads will need to be run by other tasks, until the maximum number reaches the threads.

But it seems that I can only specify certain numbers for the pool, why is it so?

As to why, I do not know either but I can imagine.

The amount of computer resources is limited. Not all resources can be handled together.

If several processes load the file simultaneously, they will be loaded sequentially (at least on a hard disk).

A processor has limited support to coordinate multiple threads simultaneously. At some point the OS or JVM Threads will have to spend more time to spend, Threads have to spend in executing their code.

This is a good reason for the Scheduled Tahrudpur Accelerator designed in the way it is designed. You can put any kind of jobs on the line, but instead of being able to run efficiently, more jobs are not performed at the same time. It is up to you that, of course, of course.

If your work is IO bound, then I can reduce the size of the pool, and if they are bound to the CPU, then a little larger (32 or so). You can do more than one Scheduled ThreadPoolExecutor s, for an IO bound task and for a CPU-bound task


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -