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

点点圈 提交于 2020-01-11 04:45:09

问题


Why ForkJoinPool was forked for Scala?

Which implementation and for which case is preferred?


回答1:


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.

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

https://github.com/scala/scala/commit/76e9da2ca4c31daec2b04848c3c2dbad6ecd426e

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.



来源:https://stackoverflow.com/questions/14562070/scala-concurrent-forkjoin-forkjoinpool-vs-java-util-concurrent-forkjoinpool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!