In the exam lab explanation ,it's written that doVIP would be called 3 times by each thread the output is:
000000
i cannot get how is this output occuring .. iand each thread is assigning it's own value ti
static volatile int x=0;
how is all zero's possible in output ?
x is static, so every instance of the class will share its value. Since the last constructor call will set the value of x to 0, so the output will contain only 0s.
Rohit, volatile is very simple, it just tells the JVM that the variable's value changes very frequently so JVM should not cache the value of this variable...