The priority makes your thread not use less CPU Time! In most threading model this will only cause your thread to be scheduled less likley making it effectifly use less CPU Time. But if this thread does computing intensive tasks it will take all the CPU power it will get and unless the thread scheduler dumps it out preemptifly the thread will work til it finishes the calculation before giving the cpu free again. Now if you want to make the CPU available to other threads you will have to give up the scheduling time by adding some waits in your calculation. At this point the thread can be rescheduled and higher prioritized threads will get the advantage.
Your best bet is to break the calculation into small chunks and let other threads have a go in between. Regards Stefan On 24 Mai, 15:45, Matt Quigley <[email protected]> wrote: > There's something in the app that happens in the background > sporadically (daily to weekly). It's CPU intensive, but I don't want > it to slow down the device. Right now, I'm creating a thread with > MIN_PRIORITY, but it doesn't seem to help in anyway from the perceived > "slowdown" of the phone while the thread is running. > > Thread thread = new Thread() { > @Override > public void run() { > // cpu-intensive stuff here... > } > }; > thread.setPriority(Thread.MIN_PRIORITY); > thread.start(); > > Some ideas I'm thinking about: > - Creating a service specifically for this thread, instead of using > the existing component (Activity/Service/etc.) it was initiated from. > - Object.wait()ing occasionally (although that really won't stop any > CPU intensive stuff from occurring) > - Putting the thread in its own service in its own process, then > giving the process minimum priority. Thing is, I don't know how to > make a process use less CPU time. > > Any tips or links on how to get a thread to use less CPU*? More > broadly, to prevent some thread from slowing Android down? > > Thanks, > -Matt > > * Technically it's not using less CPU - I still have to do the same > things. Really, it's spreading the CPU use out over more time, so > technically it's less CPU usage per unit of time. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

