Doubt about Synchronized Code Clocks
d coder
dlang.coder at gmail.com
Tue Mar 1 08:59:48 PST 2011
> I'm afraid that I have no idea what would be "stale" about a shared
variable.
> sychronized uses a mutex, and if you want to avoid race conditions, you
need to
> use mutexes or something similar when dealing with shared variables. But I
don't
> know what would be "stale" about a variable.
>
One thread modifies a shared variable and the other thread still gets an old
value. I do not know if this is applicable to D at all. Just wanted to get a
clarification after I read an article in "Java Concurrency in Practice"
book. I quote a relevant paragraph:
Locking is not just about mutual exclusion; it is also about memory
> visibility. To ensure that all threads see the most up-to-date values of
> shared mutable variables, the reading and writing must synchronize on a
> common lock.
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110301/2a0a4b23/attachment.html>
More information about the Digitalmars-d-learn
mailing list