Re: Safety Of Non-Synchronized Collections
markspace wrote:
Lew wrote:
But you don't have to understand absolutely everything about
concurrent programming to get that much right. Nor do you have to be
a master of concurrent programming, not that that's really possible,
to do any.
Not understand everything, no. But I do think you have master the basic
Java language specification in order to be able to reason about when
Did I not say essentially that?
your code is safe, and when it's not, for coding in Java. I hardly know
everything about concurrency, but I can usually write thread-safe code.
Did I not say that was the pattern?
"But you don't have to understand absolutely everything about concurrent programming ..."
It's pretty easy once you understand how.
"The /happens-before/ relationship definitely helps one to reason
correctly about [concurrency]."
But I do restrict myself to a subset of Java and concurrency. Reasoning
from first principles is hard. I try to avoid it. Using basic patterns
like immutability, safe publication, ad-hoc thread confinement and the
From my post: "Yes, you do have to understand what immutable means."
java.lang.concurrent package will get you a long ways in any concurrency
project.
"Even with knowledge, it's just so much easier to rely on immutability."
But if you haven't at least tried to reason those patterns out and
understand them in terms of the basic language specification, I don't
think you could use them successfully. Not 100% of the time; and
probably no more than 50%.
We vehemently agree.
--
Lew