Merge "Fix potential race condition with threads array."