天道酬勤,学无止境

Java多线程高并发

JAVA多线程实现多个线程同时运行

package concurrent; import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** * Auth: zhouhongliang * Date:2019/8/1 * 多个线同时运行 * CyclicBarrier */ public class CyclicBarrierDemo { private static CyclicBarrier cyclicBarrier = new CyclicBarrier(5); public static void main(String[] args) { ExecutorService executorService = Executors.newCachedThreadPool(); for (int i=0;i<10;i++){ try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); }

2021-03-27 10:15:17    分类:博客    CyclicBarrier   Java多线程高并发