java.lang.Thread.setPriority and android.os.Process.setThreadPriority
How do they differ?
Firstly, in the java.lang.Thread class
java.lang.Thread.setPriority(int priority)
priority can range from Thread.MIN_PRIORITY (= 1, the lowest) to Thread.MAX_PRIORITY (= 10, the highest).
There are related constants in the java.lang.Thread class.
public static final int MIN_PRIORITY = 1; public static final int NORM_PRIORITY = 5; public static final int MAX_PRIORITY = 10;
Secondly, in the class android.os.Process
android.os.Process.setThreadPriority(int priority)
priority can range from -20 (maximum) to 19 (lowest).
The android.os.Process class has related constants.
public static final int THREAD_PRIORITY_AUDIO = -16; public static final int THREAD_PRIORITY_BACKGROUND = 10; public static final int THREAD_PRIORITY_DEFAULT = 0; public static final int THREAD_PRIORITY_DISPLAY = -4; public static final int THREAD_PRIORITY_FOREGROUND = -2; public static final int THREAD_PRIORITY_LESS_FAVORABLE = 1; public static final int THREAD_PRIORITY_LOWEST = 19; public static final int THREAD_PRIORITY_MORE_FAVORABLE = -1; public static final int THREAD_PRIORITY_URGENT_AUDIO = -19; public static final int THREAD_PRIORITY_URGENT_DISPLAY = -8;
I found that the priority values ββare different, but I do not know why. I do not know how they work differently.
source share