Change shared variables to volatile.