并发编程系列---【模拟并发请求压测】

压测代码:

@SpringBootTest
@Slf4j
public class FastBootApplicationTest {
    /**
     * 并发数量
     */
    public static final int THREAD_NUM=14000;private static final String url="http://localhost:8084/dept/100";

    public static void main(String[] args) {
        CountDownLatch countDownLatch = new CountDownLatch(THREAD_NUM);
        for (int i = 0; i < THREAD_NUM; i++) {

            new Thread(()-> {
                {
                    try {
                        //开始倒计数,每次减1,直到计够THREAD_NUM次
                        countDownLatch.countDown();
                        //阻塞等待
                        countDownLatch.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    HttpResponse execute = HttpRequest.get(url).execute();
                    log.info(Thread.currentThread().getName()+"----返回:{}",execute.body());
                }
            },"thread"+i).start();
        }

    }

}

 

上一篇:JS 模块化从入⻔到精通


下一篇:JS的运行环境以及CommonJs和ES6的模块规范初了解