Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 93
Registered: ‎10-22-2009
My Device: Not Specified
Accepted Solution

Understanding Timertask



I am trying to understand the process of timertask. After a lot of research i understand that i extend the timertask class and create a timer.


In the run method i am wondering if i should paste my network thread code into it or just call the network thread from the run method.


Also do i just instansiate my timertask class or do i also have to call run?





Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Understanding Timertask

do not execute blocking code on a timertask.

call your network thread from the run method.

the run method is called by the scheduler (timer).

feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Posts: 93
Registered: ‎10-22-2009
My Device: Not Specified

Re: Understanding Timertask

thank you Simon

Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Understanding Timertask

Timer task is really nice to keep the Thread count down on the device.


Anything that absolutely does not require it's own thread (i.e.blocking calls to HTTP, GPS, etc) but needs to be executed under certain interval should be done under a timer task 


I know that latest BB's have a higher thread limit per app, but on earlier devices 5.0 and below you can reach the Thread limit really quickly (i.e. 15 threads would start throwing exceptions ).  Newer devices have a higher Thread limit, but TimerTask is still very convenient and recommended.