If you need to care about out of order execution (you probably work in a distributed framework), that you need to think of load load , store store and full barriers , of course if your architecture supports TSO (total store ordering) than you don't care about store barriers, your write operation will be sequential as written in the code.
If you from the other hand worry about compiler reordering , think of using Volatile (google it)
In your example store barrier will solve your problem , the implementation of such a barrier is dependent on the architecture and a compiler that you use:
e.g.
for sparc and gcc compiler :
#define MEMBAR_STORESTORE() asm volatile ("membar #StoreStore":::"memory")