Over a million developers have joined DZone.

Fork/Join in slow motion

DZone's Guide to

Fork/Join in slow motion

· Java Zone ·
Free Resource

Start coding something amazing with our library of open source Cloud code patterns. Content provided by IBM.

Have you ever wondered how fork/join algorithm really works? You can read a description but it is much better to actually see how the tasks are split, how the threads process them, how work stealing works and so on. And that’s exactly what we have done on the last GPars Hackathon. We have created demo that visualizes fork/join in slow motion.


(alternatively you can download and execute this jar

You can notice several things

  1. A thread stays in its column. Threads do not compete, each of them works on its part of the problem.
  2. If a thread is forced to steal some work it takes a big chunk so it does not have to go stealing soon again.
  3. 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.

Use this tool to look at the contents of GitHub and classify code based on the programming language used.  Content provided by IBM Developer.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}