On Tuesday 01 March 2011 06:40:31 d coder wrote: > Greetings > > I have a doubt about synchronized code blocks. > > I learnt that in Java the synchronized keyword has two fold effect. > Firstly it locks the code to make sure that only a single thread gets > access to the code block at a given time. Secondly, it makes sure that > the data elements accessed inside the code block are not "stale". As a > result Java programming practice is to synchronize even access > functions that access shared data elements. > > How about D? Does D synchronized keyword just result in mutex locking > of the code block? Or does it also ensure that the accessed shared > data elements are not stale?
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. - Jonathan M Davis