Add atomic variables to ensure thread-safety.