我们知道 JDK 19 引入了虚拟线程,实现了 JEP425 草案,https://openjdk.org/jeps/425 该案对反应式编程的批判可谓犀利:

Improving scalability with the asynchronous style

Some developers wishing to utilize hardware to its fullest have given up the thread-per-request style in favor of a thread-sharing style. Instead of handling a request on one thread from start to finish, request-handling code returns its thread to a pool when it waits for an I/O operation to complete so that the thread can service other requests. This fine-grained sharing of threads — in which code holds on to a thread only when it performs calculations, not when it waits for I/O — allows a high number of concurrent operations without consuming a high number of threads. While it removes the limitation on throughput imposed by the scarcity of OS threads, it comes at a high price: It requires what is known as an asynchronous programming style, employing a separate set of I/O methods that do not wait for I/O operations to complete but rather, later on, signal their completion to a callback. Without a dedicated thread, developers must break down their request-handling logic into small stages, typically written as lambda expressions, and then compose them into a sequential pipeline with an API (see CompletableFuture, for example, or so-called "reactive" frameworks). They thus forsake the language's basic sequential composition operators, such as loops and try/catch blocks.

In the asynchronous style, each stage of a request might execute on a different thread, and every thread runs stages belonging to different requests in an interleaved fashion. This has deep implications for understanding program behavior: Stack traces provide no usable context, debuggers cannot step through request-handling logic, and profilers cannot associate an operation's cost with its caller. Composing lambda expressions is manageable when using Java's stream API to process data in a short pipeline, but problematic when all of the request-handling code in an application must be written in this way. This programming style is at odds with the Java Platform because the application's unit of concurrency — the asynchronous pipeline — is no longer the platform's unit of concurrency.

在 golang 大行其道时 java 也算与时俱进了,愿 VirtualThread 的性能能不负所望。

JDK 19 对反应式编程的批判的更多相关文章

  1. Project Reactor 响应式编程

    目录 一. 什么是响应式编程? 二. Project Reactor介绍 三. Reactor核心概念 Flux 1. just() 2. fromArray(),fromIterable()和 fr ...

  2. 07-Spring5 WebFlux响应式编程

    SpringWebFlux介绍 简介 SpringWebFlux是Spring5添加的新模块,用于Web开发,功能和SpringMvc类似的,WebFlux使用当前一种比较流行的响应式编程框架 使用传 ...

  3. Objective-C 链式编程思想

    链式编程思想 链式编程是什么 链式编程就是将调用多个方法用点语法连接起来,让代码更加简洁和可读性更高刚开始接触链式编程是Masonry,用起来真的非常爽 1 make.left.right.top.e ...

  4. 使用ReactiveCocoa实现iOS平台响应式编程

    使用ReactiveCocoa实现iOS平台响应式编程 ReactiveCocoa和响应式编程 在说ReactiveCocoa之前,先要介绍一下FRP(Functional Reactive Prog ...

  5. [转]使用ReactiveCocoa实现iOS平台响应式编程

    原文:http://www.itiger.me/?p=38 使用ReactiveCocoa实现iOS平台响应式编程 ReactiveCocoa和响应式编程 在说ReactiveCocoa之前,先要介绍 ...

  6. springboot2 webflux 响应式编程学习路径

    springboot2 已经发布,其中最亮眼的非webflux响应式编程莫属了!响应式的weblfux可以支持高吞吐量,意味着使用相同的资源可以处理更加多的请求,毫无疑问将会成为未来技术的趋势,是必学 ...

  7. [转]springboot2 webflux 响应式编程学习路径

    原文链接 spring官方文档 springboot2 已经发布,其中最亮眼的非webflux响应式编程莫属了!响应式的weblfux可以支持高吞吐量,意味着使用相同的资源可以处理更加多的请求,毫无疑 ...

  8. 【SpringBoot】SpringBoot2.0响应式编程

    ========================15.高级篇幅之SpringBoot2.0响应式编程 ================================ 1.SprinBoot2.x响应 ...

  9. Angular4学习笔记(五)- 数据绑定、响应式编程和管道

    概念 Angular中的数据绑定指的是同一组件中控制器文件(.ts)与视图文件(.html)之间的数据传递. 分类 流向 单向绑定 它的意思是要么是ts文件为html文件赋值,要么相反. ts-> ...

  10. WebFlux基础之响应式编程

    上篇文章,我们简单的了解了WebFlux的一些基础与背景,并通过示例来写了一个demo.我们知道WebFlux是响应式的web框架,其特点之一就是可以通过函数式编程方式配置route.另外究竟什么是响 ...

随机推荐

  1. C4996 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

    错误原因 VS平台认为scanf函数不安全,要求换成scanf_s函数 解决方案 方案一:将scanf换成scanf_s[不建议] 将scanf换成scanf_s 但是,scanf_s函数只能在vs上 ...

  2. 【VMware VCF】使用 SoS 实用程序检查 VCF 环境的运行状态以及收集组件的日志信息。

    VMware Cloud Foundation 解决方案中有一个叫 Supportability and Serviceability(SoS)可支持性和可维护性的实用程序,可能你在初始构建 VCF ...

  3. Android Qcom USB Driver学习(四)

    VID/PID识别USB设备 CDC-ACM驱动介绍 CDC-ACM(Communication Device Class--Abstract Control Model)驱动实现以USB设备驱动和t ...

  4. Need BLUETOOTH PRIVILEGED permission以及requestMtu导致蓝牙断连问题

    在部分Android手机上,当连接上GATTService后直接requestMtu有可能会造成蓝牙连接中断,随后继续重新连接会报错Need BLUETOOTH PRIVILEGED permissi ...

  5. kotlin协程——>基础、取消与超时

    Kotlin使用挂起函数为异步操作,使用kotlinx.coroutines中的launch.async 1. 第⼀个协程程序 import kotlinx.coroutines.* fun main ...

  6. Oracle新增日志组成员

    Oracle新增日志组成员 查询当前的日志组信息: sql SELECT * FROM v$log; 查询日志组对应的日志文件: sql SELECT * FROM v$logfile; 查询日志组的 ...

  7. 如何使用 GoGoCode 一键 Vue2 转换 Vue3

    前言 从今年年初开始,项目开始升级优化,将之前的 Vue2 旧版本整体升级到 Vue3 版本.在重写了几个 Vue 文件后,我发现做的都是一些机械性的工作,效率低且重复性大.于是就试着搜索了一下有没有 ...

  8. nginx原理剖析

    当我们启动nginx服务之后,可以使用如下命令查看nginx进程 显然易见,nginx大致分为master以及worker两部分: master-workers 机制 首先./nginx -s rel ...

  9. 学习JavaScript第一天

    文章目录 1.JavaScript简介 2.JavaScript编写的位置 2.1.内部JavaScript 2.2外部JavaScript 2.3内联JavaScript 3.JavaScript注 ...

  10. Vue生态工具组合

    文章目录 1.Vue版本 2.构建工具 3.包管理器 4.状态管理 5.http库 6.UI库 7.站点生成器 8.优质内容收录 vue生态工具多种多样,我们要如何选择并组合起来才最好呢.接下来给大家 ...