<br>> I'm afraid that I have no idea what would be "stale" about a shared variable.<br>> sychronized uses a mutex, and if you want to avoid race conditions, you need to<br>> use mutexes or something similar when dealing with shared variables. But I don't<br>
> know what would be "stale" about a variable.<br>><br><br>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:<br>
<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
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.</blockquote>
<div><br></div><div>Regards </div>