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 并行流?
基础教程推荐
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 多个组件的复杂布局 2022-01-01
- Java Swing计时器未清除 2022-01-01
