Timertask thread priority

Put your problem here if it does not fit any of the other categories.

Timertask thread priority

Postby sanyiii » Tue Jun 01, 2010 8:49 am

Hi everybody,

I have a simple question:
I have a Timer in my application with 3 TimerTask. If I modify the thread priority in one of these TimerTask to lowest, i modifies the timer, or only the TimerTask? So my other 2 TimerTasks will be run on the default priority?
sanyiii
Developer
Developer
 
Posts: 42
Joined: Wed Jun 10, 2009 9:58 am

Top

Re: Timertask thread priority

Postby pskink » Tue Jun 01, 2010 8:56 am

sanyiii wrote:Hi everybody,

I have a simple question:
I have a Timer in my application with 3 TimerTask. If I modify the thread priority in one of these TimerTask to lowest, i modifies the timer, or only the TimerTask? So my other 2 TimerTasks will be run on the default priority?


just curious: how can you change thread priority and why?
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Re: Timertask thread priority

Postby sanyiii » Tue Jun 01, 2010 9:12 am

How:
android.os.Process.setThreadPriority(int p)
android.permission.RAISED_THREAD_PRIORITY

Why:
I use a lot of thread in my app. Some of them are important, some of them are not. And if I modify the priorities, the app. is better optimized for speed.
sanyiii
Developer
Developer
 
Posts: 42
Joined: Wed Jun 10, 2009 9:58 am

Re: Timertask thread priority

Postby pskink » Tue Jun 01, 2010 9:21 am

sanyiii wrote:How:
android.os.Process.setThreadPriority(int p)
android.permission.RAISED_THREAD_PRIORITY

it changes current thread prioity - Timer uses its own thread - you dont have acces to it

sanyiii wrote:Why:
I use a lot of thread in my app. Some of them are important, some of them are not. And if I modify the priorities, the app. is better optimized for speed.


probably you should replace them with Handlers if what they are not doing very heavy/blocking operations
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Re: Timertask thread priority

Postby sanyiii » Tue Jun 01, 2010 9:35 am

it changes current thread prioity - Timer uses its own thread - you dont have acces to it

So a TimerTask code runs on a different thread than other TimerTask codes?

probably you should replace them with Handlers if what they are not doing very heavy/blocking operations

The non important tasks not often touches the UI (for example, one of these threads are sending an usage report).
My customer wants a lot of things to do in the application, what takes away a lot of CPU time from the important threads. And it can be annoying for the user.
But now, my app. runs fast on slow phones too. So it's enough good solution for me.
sanyiii
Developer
Developer
 
Posts: 42
Joined: Wed Jun 10, 2009 9:58 am

Re: Timertask thread priority

Postby pskink » Tue Jun 01, 2010 9:39 am

sanyiii wrote:So a TimerTask code runs on a different thread than other TimerTask codes?


no, all TimerTasks within a Timer run in the same thread - Timer's own thread
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Top

Re: Timertask thread priority

Postby sanyiii » Tue Jun 01, 2010 9:42 am

no, all TimerTasks within a Timer run in the same thread - Timer's own thread


Ok, thanks!
sanyiii
Developer
Developer
 
Posts: 42
Joined: Wed Jun 10, 2009 9:58 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 11 guests