Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 this calls important? Thanks

like image 823
Addev Avatar asked Apr 07 '26 03:04

Addev


1 Answers

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).

like image 193
CrackerJack9 Avatar answered Apr 09 '26 17:04

CrackerJack9



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!