> 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
