一、高并发:
@Service
public class ConcurrentTest {
/**
* 线程数量
*/
public static final int THREAD_NUM = 100;
/**
* 开始时间
*/
private static long startTime = 0L;
@PostConstruct
public void init() {
try {
startTime = System.currentTimeMillis();
System.out.println("CountDownLatch started at: " + startTime);
// 初始化计数器为1
CountDownLatch countDownLatch = new CountDownLatch(1);
for (int i = 0; i < THREAD_NUM; i ++) {
new Thread(new Run(countDownLatch)).start();
}
// 启动多个线程
countDownLatch.countDown();
} catch (Exception e) {
System.out.println("Exception: " + e);