Fork/Join in slow motion
(alternatively you can download and execute this jar)
You can notice several things
- A thread stays in its column. Threads do not compete, each of them works on its part of the problem.
- If a thread is forced to steal some work it takes a big chunk so it does not have to go stealing soon again.
- It does not run in the sandbox. Th jsr166y library uses sun.misc.Unsafe which is not part of public SDK API. That’s why you have to trust my self-signed certificate.
Source codes are available here (Groovy, Java). The demo was brought to you by me, Jety and Václav.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)