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 并行流?
基础教程推荐
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 降序排序:Java Map 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01