How volatile keyword works in java