23. JUC: CPU-intensive and io-intensive

Watch the video of the learning process: [Crazy God Says Java]
https://www.bilibili.com/video/BV1B7411L7tE?p=13
Welcome everyone to support Oh, very conscientious teacher!

What is the maximum value of the thread pool?

1. CPU intensive

Depending on how many cores your server is, you can set up as many cores as possible to keep CPu at the highest efficiency!

2. IO-intensive

When your program has very IO-consuming threads.
Set the maximum thread value> the number of threads that consume IO very much.

How does the code get the number of CPU cores

public class Test3 {
    
    
    public static void main(String[] args) {
    
    
        System.out.println(Runtime.getRuntime().availableProcessors());
    }
}

operation result:
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_41347385/article/details/110130940