Post

barrier

public static void main(String[] args) throws InterruptedException, BrokenBarrierException {
    ExecutorService executorService = Executors.newFixedThreadPool(10);

    RestTemplate restTemplate = new RestTemplate();
    String url = "URL";
    String data = "";
    CyclicBarrier cyclicBarrier = new CyclicBarrier(11);

    AtomicInteger counter = new AtomicInteger(0);
    for (int i = 0; i  {
        int idx = counter.addAndGet(1);

        cyclicBarrier.await();

        ResponseEntity result = restTemplate.postForEntity(url, data, String.class);

        System.out.println(result + " " + idx);
        return null;
      });
    }

    cyclicBarrier.await();
  }

예전에 동시성 할 때 이건 잘 이해가 안됐는데 이건 팍팍된당

This article is licensed under CC BY 4.0 by the author.