https://www.ixigua.com/6851821702415188493?id=6851553614264173060&logTag=a_eppPQeUS_ygL_yLphP1
package com.zhenzhen.demo.user;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.zhenzhen.demo.user.service.UserService;
@RunWith(SpringRunner.class)
@SpringBootTest
public class UserApplicationTests {
private static final int MAX_THRED = 1000;
private static CountDownLatch countDownLatch = new CountDownLatch(MAX_THRED);
@Autowired
private UserService userService;
@Test
public void testConcurrentRequest() throws InterruptedException {
for(int i=0;i<MAX_THRED;i++) {
new Thread(()->{
try {
countDownLatch.countDown();
countDownLatch.await();
Map<String,Object> result = userService.getOrderNew("usreId");
System.out.println(result);
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
Thread.sleep(5000);
}
}