[concurrency-interest] How to implement task-local variables (like thread local variables but for Fork/Join tasks)
Dr Heinz M. Kabutz
heinz at javaspecialists.eu
Mon Aug 8 09:19:13 EDT 2016
Could you perhaps post some code demonstrating what you are trying to
On Monday, 8 August 2016, Per Mildner <perm at sics.se> wrote:
> > I need something that should behave like a thread-local variable but for
> a tree of RecursiveAction tasks.
> > That is, a task inherits the task-local variables from the task that
> created it. Looking up a task-local variable is done by traversing the
> chain of parent tasks, looking for special task instances that holds task
> local values.
> > I currently implement this by letting all tasks know their parent (the
> “current task”) which is passed to their constructor. This way I can
> traverse the chain of parents towards the root of the task tree.
> > Keeping track of the current task is done by making all tasks set and
> restore themselves as the “current task” in a thread-local variable in
> their RecursiveAction.compute() but that seems wasteful since it is done
> also when the the task is running in the same thread as its parent task.
> > So, any ideas how to implement this efficiently?
> > Even better, is there a way to make something like this work with the
> default pool?
> > Regards,
> > Per Mildner
> > (I sent this earlier but it never seemed to arrive at the list. Sorry if
> it gets duplicated.)
> Per Mildner Per.Mildner at sics.se
> Swedish Institute of Computer Science (SICS Swedish ICT)
> Concurrency-interest mailing list
Dr Heinz M. Kabutz (PhD CompSci)
Author of "The Java(tm) Specialists' Newsletter"
Sun/Oracle Java Champion
JavaOne Rockstar Speaker
Tel: +30 69 75 595 262
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest