Java8 Stream(9)List集合查找 findFirst、findAny、anyMatch、allMatch、noneMatch 您所在的位置:网站首页 列表的第一个元素 Java8 Stream(9)List集合查找 findFirst、findAny、anyMatch、allMatch、noneMatch

Java8 Stream(9)List集合查找 findFirst、findAny、anyMatch、allMatch、noneMatch

2023-08-23 20:38| 来源: 网络整理| 查看: 265

Java8 CompletableFuture(6) thenCompose和thenCombine的区别

麻麻歪: 代码是非阻塞

Java8 CompletableFuture(6) thenCompose和thenCombine的区别

麻麻歪: thenCompose是同步的,你阻塞前一个CompletableFuture第二个CompletableFuture的所有业务是不会执行的(不阻塞同理),而thenCombine的第一个入参CompletionStage是异步的,合并结果的BiFunction是同步的[code=java] CompletableFuture i = CompletableFuture.supplyAsync(() -> { long startTime = System.currentTimeMillis(); while (true){long currentTime = System.currentTimeMillis();long elapsedTime = currentTime-startTime;if (elapsedTime >= 3000){break;}}System.out.println("运行三秒");return 6; }).thenCompose(t -> CompletableFuture.supplyAsync(() -> { System.out.println("不是先打印,不是异步");return 5+t; })).thenCombine(CompletableFuture.supplyAsync(() -> { SleepHelper.sleepMilli(2000);System.out.println("先打印 异步");return 9; }), (integer1, integer2) -> integer1 * integer2);System.out.println(i.join());} // 先打印 异步 // 运行三秒 // 不是先打印,不是异步 // 99 [/code]

Elasticsearch教程(27) ES拼接查询条件的工具类

命运狂想曲回来了: StateEnum这个枚举有吗

前端笔记(4) Vue3 全局属性 app.config.globalProperties 使用案例

undefined_zzk: 谁请求接口挂载到这上面 表情包

Elasticsearch教程(21) 详解mapping之boolean

瑟王: 谢谢啦,注意休息



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有