It is impossible to set based on the number of CPU cores. What if the number of threads in a quad-core CPU can only be 4 at most? There are definitely more.
When writing, you can set the maximum number of concurrent threads yourself, Executors.newFixedThreadPool(num);
Generally, it depends on how many cores and threads the CPU has. After all, the performance of a mobile phone cannot be compared with that of a computer. It must be set according to the performance of the mobile phone itself.
It has nothing to do with CPU. For this kind of multi-threaded download or multi-threaded IO, the bottleneck is not the CPU, but the response speed of the IO asynchronous callback. This is not the same as concurrent compilation. It doesn't matter if you open multiple threads, the memory overhead won't be much.
Not only should you look at the number of CPU cores, but also the proportions of the CPU calculation part and the IO operation part in your operation to see where the bottleneck is If you don’t mind it, you can use systrace to observe it Here’s the specific execution process
It is impossible to set based on the number of CPU cores. What if the number of threads in a quad-core CPU can only be 4 at most? There are definitely more.
When writing, you can set the maximum number of concurrent threads yourself, Executors.newFixedThreadPool(num);
Generally, it depends on how many cores and threads the CPU has. After all, the performance of a mobile phone cannot be compared with that of a computer. It must be set according to the performance of the mobile phone itself.
It has nothing to do with CPU. For this kind of multi-threaded download or multi-threaded IO, the bottleneck is not the CPU, but the response speed of the IO asynchronous callback. This is not the same as concurrent compilation. It doesn't matter if you open multiple threads, the memory overhead won't be much.
It is said that setting the number of threads to the number of CPUs + 1 would be better
Not only should you look at the number of CPU cores, but also the proportions of the CPU calculation part and the IO operation part in your operation to see where the bottleneck is
If you don’t mind it, you can use systrace to observe it Here’s the specific execution process