java线程池多线程优先级
Priority of a thread describes how early it gets execution and selected by the thread scheduler. In Java, when we create a thread, always a priority is assigned to it. In a Multithreading environment, the processor assigns a priority to a thread scheduler. The priority is given by the JVM or by the programmer itself explicitly. The range of the priority is between 1 to 10 and there are three constant variables which are static and used to fetch priority of a Thread. They are as following:
线程的优先级描述了线程调度程序提早执行和选择线程的时间。 在Java中,当我们创建线程时,总是为其分配优先级。 在多线程环境中,处理器将优先级分配给线程调度程序。 优先级由JVM或程序员本身明确指定。 优先级的范围在1到10之间,并且有三个常量,它们是静态的,用于获取线程的优先级。 它们如下:
1. public static int MIN_PRIORITY (1. public static int MIN_PRIORITY)
It holds the minimum priority that can be given to a thread. The value for this is 1.
它拥有可以赋予线程的最低优先级。 该值为1。
2. public static int NORM_PRIORITY (2. public static int NORM_PRIORITY)
It is the default priority that is given to a thread if it is not defined. The value for this is 0.
如果未定义,则它是赋予线程的默认优先级。 该值为0。
3. public static int MAX_PRIORITY (3. public static int MAX_PRIORITY)
It is the maximum priority that can be given to a thread. The valu