From b35c23b897facc8f629333d05e3cb94519df826e Mon Sep 17 00:00:00 2001 From: phh Date: Sun, 12 Jul 2020 15:17:58 +0100 Subject: [PATCH] 8237117: Better ForkJoinPool behavior Reviewed-by: mbalao, andrew --- .../java/util/concurrent/ForkJoinWorkerThread.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java index 8723f0aac..2444d09ec 100644 --- a/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java +++ b/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java @@ -73,6 +73,11 @@ public class ForkJoinWorkerThread extends Thread { final ForkJoinPool pool; // the pool this thread works in final ForkJoinPool.WorkQueue workQueue; // work-stealing mechanics + /** An AccessControlContext supporting no privileges */ + private static final AccessControlContext INNOCUOUS_ACC = + new AccessControlContext( + new ProtectionDomain[] { new ProtectionDomain(null, null) }); + /** * Creates a ForkJoinWorkerThread operating in the given pool. * @@ -82,6 +87,7 @@ public class ForkJoinWorkerThread extends Thread { protected ForkJoinWorkerThread(ForkJoinPool pool) { // Use a placeholder until a useful name can be set in registerWorker super("aForkJoinWorkerThread"); + U.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, INNOCUOUS_ACC); this.pool = pool; this.workQueue = pool.registerWorker(this); } @@ -215,13 +221,6 @@ public class ForkJoinWorkerThread extends Thread { private static final ThreadGroup innocuousThreadGroup = createThreadGroup(); - /** An AccessControlContext supporting no privileges */ - private static final AccessControlContext INNOCUOUS_ACC = - new AccessControlContext( - new ProtectionDomain[] { - new ProtectionDomain(null, null) - }); - InnocuousForkJoinWorkerThread(ForkJoinPool pool) { super(pool, innocuousThreadGroup, INNOCUOUS_ACC); } -- GitLab