changed bool to atomic<bool>