![]() ![]() MessageQueue is a simply queue that has tasks called messages which should be processed.The thread is terminated when it is done with execution of all the tasks.Īndroid framework also uses the model via Looper, Handler and HandlerThread in the following way:.The task is executed serially by that thread and is maintained in the queue ( Message Queue).The thread is kept alive in the loop by its run() method.So the best solution would be to create reasonable amount of threads and use them for all the tasks. ![]() One may wonder we can do improvements by dispatching tasks among multiple of execution threads, however, it is also very slow because creation of multiple threads is overhead. The problem with Java thread is they are one time use only, and die after executing its run method. Question may appear "why on earth we need to worry about loopers, and handlers when java already provides us with thread APIs for multi-threading programming"? It is actually very good question. So understanding loopers and handlers will help to understand those third parties libraries.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |