scala.concurrent.forkjoin.ForkJoinPool vs java.util.concurrent.ForkJoinPool [英] scala.concurrent.forkjoin.ForkJoinPool vs java.util.concurrent.ForkJoinPool

查看:176
本文介绍了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:

https://github.com/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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆