本文介绍了在Java EE容器中使用Java 8并行流是否不鼓励?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于。将使用可能产生线程的在Java EE内部也不鼓励?

解决方案

从:产生线程的方式不是不鼓励 - 但不会在Java EE环境中为您做任何事情。



从链接的讨论中:

所以,您可以在程序或库中安全地使用并行流在两个上下文中运行。当它在SE环境中运行时,它将与魔法平行的shenanigans一起使用 - 但是当它在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?

解决方案

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.

From the linked discussion:

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并行流是否不鼓励?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 00:04