Is it discouraged to use Java 8 parallel streams inside a Java EE container?(是否不鼓励在 Java EE 容器中使用 Java 8 并行流?)
问题描述
鉴于 不鼓励在 Java EE 容器中生成线程.将使用 Java 8 并行流,这可能会产生线程,Java EE内部也气馁?
Given that spawning threads in Java EE containers are discouraged. Would using the Java 8 parallel streams, which may spawn threads, inside Java EE be discouraged too?
推荐答案
EDIT 查看 andrepnh
的替代答案.以下可能是计划,但在实践中似乎并没有这样发展.
EDIT See alternate answer from andrepnh
. The below may have been the plan, but it doesn't appear to have played out that way in practice.
我从 lambda-评论中提到的开发邮件列表讨论:生成线程的方式并不气馁 - 但在 Java EE 上下文中不会为您做任何事情.
The way I read it from the lambda-dev mailing list discussion mentioned in the comments: it's not discouraged the way spawning threads is - but won't do anything much for you in a Java EE context.
来自链接的讨论:
Java EE 并发人员已经讨论过这个,目前的结果是 FJP 将优雅地降级为从内部运行时的单线程(甚至调用者上下文)执行EE 容器
the Java EE concurrency folks had been already talked through this, and the current outcome is that FJP will gracefully degrade to single-threaded (even caller-context) execution when running from within the EE container
因此,您可以在同时在两种上下文中运行的过程或库中安全地使用并行流.当它在 SE 环境中运行时,它会使用神奇的并行恶作剧——但当它在 EE 环境中运行时,它会优雅地降级为串行执行.
So you're able to safely use parallel streams in a procedure or library that runs in both contexts. When it's run in a SE environment, it will make with the magical parallel shenanigans - but when it's run in an EE environment it will gracefully degrade to serial execution.
注意:上面引用的短语是将来时 - 是否有人引用了某些权威文档?
Note: the phrase quoted above is future tense - does anyone have a citation for some definitive documentation?
这篇关于是否不鼓励在 Java EE 容器中使用 Java 8 并行流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否不鼓励在 Java EE 容器中使用 Java 8 并行流?
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01