Fixed potential race condition when running on many threads locally