Declare shared variable as volatile to prevent stale copies