B
blmblm
1 represents a lock A lock that is required to modify various things. I
happened to choose a simple example with just one variable A.
Which is caused because you unlocked too early! This madness, you are
agreeing with me whilst disagreeing .
But the "too early" is "too early relative to modifying A", not "too
early relative to releasing other locks." If you released all three
locks in the order you think proper (reverse of acquisition order),
and then modified A, you would have the same problem, no?
From what I have read in this
discussion if you don't believe the
release-in-reverse-order-to-acquisition rule you won't agree with the
rest of what I've written.
You're right. You haven't said anything that convinces me that
there are safety problems caused by the order in which one releases
locks.
I probably shouldn't have mentioned any of this at all as it doesn't
apply to Java due to the way the language is constructed. We don't
appear to be getting anywhere with this so best to leave it. It appears
that you have come to the same conclusion.
Pretty much. I'm troubled by the contradiction between what you say
(which sounds like it's based on real-world experience) and what
I understand to be true from textbook discussions of synchronization
mechanisms, though, so I'm having trouble just dropping it.
So maybe one more comment, and a question.
The comment: I'm basing what I say not on the specifics of how
Java performs locking and unlocking -- which I admit I do not know
details of -- but on my understanding of synchronization mechanisms
and deadlocks in general, more or less as learned from textbooks on
operating systems.
The question: What's special about Java, such that order in which
locks are released doesn't matter, where it does in other languages /
APIs?