Remove locking in favour of a volatile state variable.