March 01, 2011
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?

Thanks and Regards
- Puneet