Is there any point in having multiple Handlers if they use the same Looper?
eg:
private Handler firstHandler = new Handler(Looper.getMainLooper());
private Handler secondHandler = new Handler(Looper.getMainLooper());
firstHandler.post(...);
secondHandler.post(...);
... they both post to the main thread, is that pointless to have the second one?
Thanks.
Yes.
Quoted from the Docs:
Those Handlers are sending messages to the same
MessageQueue, so anyway the second one will run after the first one is done, meaning it's redundant.Further more, The
Handleris associated with theThreadit's created in by default. So if theHandleris created on themain threadyou don't have to specify a Looper.