Replaced bool+mutex with atomic_bool