• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Wanna know about Runnable and Handler

Estgobi

Lurker
Hi All,
I'm newbie to android.and i have some doubts about Handlers and runnable.

1.
Code:
 mHandler.postDelayed(mUpdateTimeTask, 5000);


where mUpdateTimeTask is the object of runnable.

a)when the above call add the message in to the message queue.imm or after 5 sec.
b)How they are achieving 5 sec delay, Is there any thread running background ?
2.
Code:
private Runnable mUpdateTimeTask = new Runnable() {
                   public void run() {
                                }

                        }


a) will the above code create a thread, If yes , what would be the thread name and priority? If No, is it act as a Callback in this context?


Regards,
Gobi.S
 
1.a) A timer is created. When the timer fires, the runnable will be added to the queue.
1.b) No background thread is created. Timers are provided by the Linux kernel.
2.a) Your runnable will run on the main thread.
 
Back
Top Bottom