java.lang.Thread.setPriority
and android.os.Process.setThreadPriority
How are they different?
First, in the java.lang.Thread
class,
java.lang.Thread.setPriority(int priority)
priority
can have a value from Thread.MIN_PRIORITY
( = 1, Lowest) to Thread.MAX_PRIORITY
( = 10, 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;
Second, in the android.os.Process
class,
android.os.Process.setThreadPriority(int priority)
priority
can have a value from -20 (Highest) to 19 (Lowest).
There are related constants in the android.os.Process class.
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 don't know why. I don't know how they work differently.