1

I am making multiple REST API request calls to a third party app from java and I do not know the threshold value of number of requests they procees in a given time and I am thrown a 429 too many requests runtime exception, I need to add a delay between these API calls can anyone suggest an optimal way(there are no threads used in the app)

1 Answers1

4

You can use Handler.postDelayed() method:

new Handler().postDelayed(new Runnable() {  
    @Override
    public void run() {
        // do something that is meant to be delayed
    }
}, delayMillis);

where delayMillis is delay time measured in milliseconds.

Piotr Chojnacki
  • 6,837
  • 5
  • 34
  • 65