09-14-2010 11:26 AM
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?
Solved! Go to Solution.
09-14-2010 11:34 AM
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).
09-14-2010 11:40 AM
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.