The deadlock is happening when you have your local
calling a threaded operation on confirmUpdate
when other
is attempting to make the same call. Hence, the deadlock happens following this order of operations
Local
locks itself by callingpropagateUpdate
due to the declaration that it issynchronized
(see Synchronized Member Function in Java)- 'Other' locks itself by calling
propagateUpdate
Local
attempts to acquire the lock onOther
to callconfirmUpdate
but can't sinceOther
has already been locked in the other thread.Other
attempts to do the same thing and fails for the same reason.
If it's actually working, it's probably because it's happening so fast. Run it a few more times. Thread issue never work when you want them to work.