0

I want to do over 1000 PUT synchronously requests and I want to do break between.

        HttpClient client = HttpClient.newHttpClient()

        for (int i=0; i<1000; i++) {
            HttpRequest request = HttpRequest.newBuilder()
                    .header("Content-Type", "application/json")
                    .header("Authorization", "Bearer " + token)
                    .uri(URI.create(url))
                    .PUT(HttpRequest.BodyPublishers.ofString(body))
                    .build();

            HttpResponse<String> response;

            response = client.send(request, HttpResponse.BodyHandlers.ofString());
macmar22
  • 31
  • 1
  • 1
  • 5
  • Waiting in synchronous Java is still the same no matter what HTTP client you use. Thus this is a possible duplicate of https://stackoverflow.com/questions/24104313/how-do-i-make-a-delay-in-java – Robert Apr 07 '21 at 11:14
  • looks like you should use `Thread.sleep(1000)` for interval – Ryuzaki L Apr 07 '21 at 14:27

0 Answers0