switch to use atomic counters for tracking active threads