Handler和Runnable常见的问题

提问者的大意以下: post

    在一个非UI线程中,若是连续给Handler对象post两个Runnable对象,那么第二个Runnable对象是否是须要等到第一个Runnable对象执行完以后才开始执行。 ui


答案: spa

    是的,第二个Runnable对象须要等到第一个Runnable对象执行完成以后才能开始执行。 线程


问题出处: 对象

http://stackoverflow.com/questions/8336579/does-handler-execute-runnables-simultaneously
ci





提问者的大意以下: it

    在主UI线程中,使用handler.post(Runnable r)方法是否会建立一个新的线程? io


答案: thread

    不会,这个Runnable仍是在主UI线程中。 变量


问题出处:
http://stackoverflow.com/questions/9163411/does-handler-postrunnable-start-a-new-thread






提问者的大意以下:

    怎么给Runnable传入参数?


答案:

    · 在构造Runnable的时候把参数写成它的成员变量;

    · 把要传入的参数用final进行修饰;

    · 使用Callable


问题出处:

http://stackoverflow.com/questions/9123272/is-there-a-way-to-pass-parameters-to-a-runnable



问题大意:

    Acticity.runOnUiThread(Runnable action) 和 Handler.post(Runnable r)的区别?


问题出处:

http://stackoverflow.com/questions/1839625/whats-the-difference-between-activity-runonuithreadrunnable-action-and-handler





问题大意:

    Runnable是用来实现Thread中run()方法的代码,自己和Thread没有任何关系。


问题出处:

http://stackoverflow.com/questions/9029795/new-runnable-but-no-new-thread

相关文章
相关标签/搜索