scala.concurrent.forkjoin.ForkJoinPool vs java.util.concurrent.ForkJoinPool

编程入门 行业动态 更新时间:2024-10-22 05:08:59
本文介绍了scala.concurrent.forkjoin.ForkJoinPool vs java.util.concurrent.ForkJoinPool的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

为什么ForkJoinPool是为Scala分叉的?

Why ForkJoinPool was forked for Scala?

首选哪种实现以及哪种情况?

Which implementation and for which case is preferred?

推荐答案

scala库拥有自己的ForkJoinPool副本的一个明显原因是scala必须在1.7之前的JVM上运行,并且 ForkJoinPool 是仅在Java 1.7中引入。

The obvious reason for the scala library to have its own copy of ForkJoinPool is that scala must run on pre-1.7 JVMs, and ForkJoinPool was only introduced in Java 1.7.

此外,对内部(scala)使用进行了一些更改,例如:

In addition, there were a few changes made for internal (scala) use, such as this:

github/scala/scala/commit/76e9da2ca4c31daec2b04848c3c2dbad6ecd426e

鉴于scala的版本可能不会给你带来任何好处(如果你正在编译并运行java 1.7),我会说你自己使用的应该使用java的版本。至少java的版本是精确记录的并且完全公开,而scala版本的状态不清楚(它可能非常适合仅供内部使用)。但是在某些地方你可能没有任何选择。例如 ForkJoinTasks 有一个 forkJoinPool 方法,期望scala的版本 ForkJoinPool 。如果某人能够获得/找到scala版本 ForkJoinPool 的任何官方状态,说明它真的公开且稳定,那么我很乐意回复这个建议。

Given that scala's version will probably not give you any advantage (if you are compiling and running against java 1.7), I'd say that for you own use you should probably use java's version. At least java's version is precisely documented and fully "public", while the status of scala's version is unclear (it might very well be intended for internal use only). However in some places you might not have any choice. By example ForkJoinTasks has a forkJoinPool method that expects scala's version of ForkJoinPool. If someone can get/find any official status for scala's version of ForkJoinPool stating that it's really public and stable, then I'll happily revert this advice.

更多推荐

scala.concurrent.forkjoin.ForkJoinPool vs java.util.concurrent.ForkJoinPool

本文发布于:2023-11-25 13:58:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630038.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:forkjoin   concurrent   scala   util   java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!