开发者

Granting a Thread low priority in Android

开发者 https://www.devze.com 2023-03-26 14:15 出处:网络
If I wantgrant a Thread a low priority whats the correct call? Thread t= new Thread(r); t.setPriority(Thread.MIN_PRIORITY);

If I want grant a Thread a low priority whats the correct call?

Thread t= new Thread(r);
t.setPriority(Thread.MIN_PRIORITY);

or

Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);

Or maybe should I combine both? If yes is the order of开发者_JAVA技巧 this calls important? Thanks


t.setPriority(int) will set the priority on Thread t. This can not be used to set a Thread's priority higher than the receiver's ThreadGroup.

Process.setThreadPriority(int, int) takes an additional argument, so that you can set the priority on any Thread (granted a SecurityException is not thrown).

Also notice the integer value of Thread.MIN_PRIORITY (1) and Process.THREAD_PRIORITY_LOWEST (19).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号