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 并行流?
基础教程推荐
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
