volatile

Volatile Variables and Happens before ordering

I have two threads: Thread:1 a = 1; x = b; Thread:2 b = 1 y = a Here a and b are declared volatile. I did not understand how a "happens-before" edge is created between a = 1; and y = a; and between x = b; and b = 1; I understand that by using volatile variable one can prevent reading stale values from thread cache. But how can a ...