Implemented std::thread/atomic toggle.