Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Why ForkJoinPool was forked for Scala?

Which implementation and for which case is preferred?

like image 707
Andriy Plokhotnyuk Avatar asked Jan 28 '13 12:01

Andriy Plokhotnyuk


1 Answers

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.

like image 76
Régis Jean-Gilles Avatar answered Sep 21 '22 16:09

Régis Jean-Gilles