hi,
im reading a tutorial and tried to run Safelock example shown in
HERE When i run this program the first output lines are :
Gaston: Alphonse has bowed back to me!
Gaston: Alphonse has bowed to me!
And i cant undestand how the first line can be "Gaston: Alphonse has bowed back to me", if the first output statement in method "bow" is "...
bowed to me..." and both bowee and bower objects are locked for certain
thread. so i thought if one thread started some method it has to do all statements in the order they are written and others threads cannot interleave because of locking both objects. so in my opinion the first lines of the output shoud be :
Gaston: Alphonse has bowed to me!
Gaston: Alphonse has bowed back to me!
or the same but with different names(first output should be" has bowed to me")
tell me if i understand the flow incorectly. it would be greate if you could explain the flow of execution, which leads to such situation(first output sentence is "bowed back to me")
p.s. more often the output is the same i expected. but sometimes i get result i can't understand.
thanks and sorry for my language mistakes