How would you implement a thread-safe rate limiter for an API client that connects to a third-party service with strict rate limits?