JUC
juc
Comus_j
帅气的努力的穷困潦倒的地球人
展开
-
线程池_01
三大方法 Executor: - newSingleThreadExecutor()//单个线程 - newFixedThreadPool()//固定线程池大小 - newCachedThreadPool()//可伸缩大小的线程池 本质ThreadPoolExecutor() 七大参数 public ThreadPoolExecutor(int corePoolSize,//1:核心 int maximumPoolSize,//2最大原创 2022-05-06 15:18:50 · 57 阅读 · 0 评论 -
Stream流计算
流负责计算 public class StreamTest { public static void main(String[] args) { User user1 = new User(1,"a",21); User user2 = new User(2,"b",22); User user3 = new User(3,"c",23); User user4 = new User(4,"d",24); User us原创 2022-03-01 15:40:46 · 81 阅读 · 0 评论 -
四大函数式接口
函数式接口 @FunctionalInterface public interface Runnable { /** * When an object implementing interface <code>Runnable</code> is used * to create a thread, starting the thread causes the object's * <code>run</code> met原创 2022-03-01 14:54:26 · 42 阅读 · 0 评论 -
JUC_线程池1
public class ThreadDemo { public static void main(String[] args) { ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( 2,//核心线程数 5,//最大线程数 3,//超时无人调用释放 TimeUnit.SECONDS原创 2022-03-01 13:18:00 · 45 阅读 · 0 评论 -
Semaphore
信号量–一个计数器的信号量,信号量可以维持一组许可证,如果有必要,每个acquire()都会阻塞,知道获得许可证。然后才能唤醒它 public class SemaphoreDemo { public static void main(String[] args) { //线程数量,停车位 Semaphore semaphore = new Semaphore(3); for (int i = 1; i <=6 ; i++) {原创 2022-02-28 12:45:55 · 96 阅读 · 0 评论 -
CycliBarrier
public class CycliBarrierDemo { public static void main(String[] args) { CyclicBarrier cyclicBarrier = new CyclicBarrier(7,()->{ System.out.println("可以牛逼了!!!"); }); for (int i = 1; i <=7 ; i++) { f原创 2022-02-28 12:11:21 · 209 阅读 · 0 评论 -
CountDownLatch
public class CountDownLatchDemo { public static void main(String[] args) throws InterruptedException { //必须要执行的任务 CountDownLatch countDownLatch = new CountDownLatch(6); for (int i = 1; i <=6; i++) { new Thread(()-原创 2022-02-28 11:58:06 · 38 阅读 · 0 评论