开发者

Granting a Thread low priority in Android

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜