Re: synchronize vs gate
christopher@dailycrossword.com wrote:
*snip*
Forget the gate. Use synchronization.
--
Lew
lew
I have erased 4 replies to you already, so I will leave it at this --
I appreciate your time, I am not the dufus you seem to think I am, and
How do you conclude that I think that? I surely do not.
I will continue to use pseodocode (as I have for 20 years) against
your recommendation. I usually top-post, too.
The problem with pseudocode in a Java-specific question is that it obscures
the very issues you are trying to resolve. I am not against pseudocode, only
in favor of examples that actually exemplify.
Pseudocode cannot help resolve your question of whether to use
synchronization, which volatile is part of, because your question of
synchronization is particular to Java semantics.
As for top-posting, that's just deliberate rudeness. I can't believe you're
actually bragging about it.
No one would argue that *is not* a problem to use synchronized where
it is unnecessary, and I believe in this case it is not. I am not
But synchronization /is/ necessary, that is my point. Why do you ignore it?
Your "gate" idiom simply would not work reliably in a multithreaded context.
That was the point.
certain (obviously) and would welcome a circumstance that proves me
wrong, rather than a link to andrew's glossary gergoshsake, and some
random page (double locking??) that is completely irrelevant.
If you find it irrelevant, it's because you missed the point.
Tom, I am using 1.4 until next week when my new server is online (1.5
doesn't run on this old beast), so 'volatile' has not been an option.
I will look into it, as I think you have hit the nail on the head.
The "volatile" keyword provides synchronization, but only fully in the new
memory model. It is part of Java's synchronization mechanism, which I
mentioned was required for your code to succeed. It does work in 1.4, but
differently. I will forgo sending you the links that explain the differences,
or the dangers.
--
Lew