On 01/11/2017 06:39 PM, Martin Buchholz wrote:
Doug, please try to remember the details of the thread group code.
>
> The threadgroup creation code that uses cheating has always seemed fishy
to me. The straightforward
>
> /**
> * Returns a new group with the system ThreadGroup (the
> * topmost, parent-less group) as parent.
> */
> static final ThreadGroup createThreadGroup(String name) {
> if (name == null)
> throw new NullPointerException();
> ThreadGroup group = Thread.currentThread().getThreadGroup();
> for (ThreadGroup p; (p = group.getParent()) != null; )
> group = p;
> return new ThreadGroup(group, name);
> }
>
> passes all tests. That could be wrapped in a doPrivileged, or we could
add something more principled to ThreadGroup itself. I don't know what the
motivations are for the threadgroup code.
>
There was a some point a problem with using doPrivileged in the
context of FJP.commonPool initialization, so we went with the
suggestion of using unsafe.
And at a different point, we decided to place
all non-VarHandle-amenable code into TLR so that it could be
replaced all at once when bootstrap problems were addressed.
And at a different point (which we hope is Now :-) we can
replace the unnecessary prior workarounds.
-Doug