Search code examples
javaandroidhandlerrunnable

Does handler.post(runnable) start a new thread?


If the handler was instantiated in the main UI thread, does a post with a Runnable create a child thread that gets added to the message queue, or does it just get run in the UI thread?

handler.post(new Runnable(){
    public void run() {
        // do stuff
    }
});

Solution

  • No, it doesn't create a new thread. It simply executes your runnable on the thread your handler is attached to, which in this case means your UI thread