Reputation: 11728
Is it a bad practice to have multiple objects on a thread instantiating and using there own private handlers? Is an application supposed to instantiate and use only one handler per thread and pass it around among objects?
Upvotes: 2
Views: 1509
Reputation: 629
There are benefits to have multiple Handler
s per Looper
/MessageQueue
pair. You can send and handle different categories of Runnable
s or Message
s on respective handlers, which reduces the number of if else
to make you program more maintainable.
Upvotes: 3
Reputation: 656
remarkably - contrary to what you might think and what most people will tell you a "small thread pool" or some variation of the idea that you can understand is actually remarkably effective at maintaining overall robustness and responsiveness ~ in fact it is not only harmless but probably a good idea to try however they have their main() as doing nothing but starting a Thread Runnable and just see what it does on a prototyping bench platform as the approach most would tend to use can "trap" the main in deep convoluted heavy processor load and throw an ANR - the sooner you can release the main thread probably the better
has to be tested though
Upvotes: 1