greenrobot / EventBus

Event bus for Android and Java that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.
http://greenrobot.org/eventbus/
Apache License 2.0
24.67k stars 4.66k forks source link

Deadlock risk while register sticky event #700

Open tangnan526 opened 2 years ago

tangnan526 commented 2 years ago

When we register event listener by sticky, there is a risk of deadlock. Because when register a sticky event, it may invoke the event handler method, if the event handler method tries to acquire a lock to do something, at the same time another thread already acquires the lock and try to post an event, deadlock happend.

If we can optimize the register code to avoid this risk, that will be great!!