[concurrency-interest] Issues with ForkJoin update

Doug Lea dl at cs.oswego.edu
Fri Apr 16 12:36:52 EDT 2010


On 04/16/10 11:26, Denys Geert wrote:

> What's probably atypical about our use case is that we limit the FJ
> pool (setMaximumPoolSize).

Thanks for reporting this. I'm beginning to regret defining
a method that allows people to do this :-) The update last week
supporting better thread throttling didn't cope with this well.
I will check in another update that does in the next few days.
For now though...

>      private long computeChildTiles() {
>        CountingTask task00 = createChildTask(0, 0);
>        CountingTask task10 = createChildTask(0, 1);
>        CountingTask task01 = createChildTask(1, 0);
>        CountingTask task11 = createChildTask(1, 1);
>
>        task00.fork();
>        task10.fork();
>        task01.fork();
>        task11.fork();
>
>        long ret = 0L;
>        ret += task00.helpJoin();
>        ret += task10.helpJoin();
>        ret += task01.helpJoin();
>        ret += task11.helpJoin();
>        return ret;
>      }
>

Whenever possible, you should join tasks in LIFO order of
forking them. If you change this accordingly...
         ret += task11.helpJoin();
         ret += task01.helpJoin();
         ret += task10.helpJoin();
         ret += task00.helpJoin();
... you will avoid the issues.

-Doug






More information about the Concurrency-interest mailing list