ThreadPool( Group group, ThreadGroup parentThreadGroup ) { threadFactory = new GroupedDaemonThreadFactory( group, parentThreadGroup ); executor = group.buildExecutorService( threadFactory ); registry = new ConcurrentHashMap<>(); }
@Override public ForkJoinWorkerThread newThread( ForkJoinPool pool ) { // We do this complicated dance of allocating the ForkJoinThread in a separate thread, // because there is no way to give it a specific ThreadGroup, other than through inheritance // from the allocating thread. ForkJoinPool.ForkJoinWorkerThreadFactory factory = ForkJoinPool.defaultForkJoinWorkerThreadFactory; AtomicReference<ForkJoinWorkerThread> reference = new AtomicReference<>(); Thread allocator = newThread( () -> reference.set( factory.newThread( pool ) ) ); allocator.start(); do { try { allocator.join(); } catch ( InterruptedException ignore ) { } } while ( reference.get() == null ); ForkJoinWorkerThread worker = reference.get(); worker.setName( group.threadName() ); return worker; } }
private ExecutorService createNewWorkStealingExecutor( Group group, int parallelism, boolean asyncMode ) { ForkJoinPool.ForkJoinWorkerThreadFactory factory = new GroupedDaemonThreadFactory( group, topLevelGroup ); return new ForkJoinPool( parallelism, factory, null, asyncMode ); }
@Override public ForkJoinWorkerThread newThread( ForkJoinPool pool ) { // We do this complicated dance of allocating the ForkJoinThread in a separate thread, // because there is no way to give it a specific ThreadGroup, other than through inheritance // from the allocating thread. ForkJoinPool.ForkJoinWorkerThreadFactory factory = ForkJoinPool.defaultForkJoinWorkerThreadFactory; AtomicReference<ForkJoinWorkerThread> reference = new AtomicReference<>(); Thread allocator = newThread( () -> reference.set( factory.newThread( pool ) ) ); allocator.start(); do { try { allocator.join(); } catch ( InterruptedException ignore ) { } } while ( reference.get() == null ); ForkJoinWorkerThread worker = reference.get(); worker.setName( group.threadName() ); return worker; } }
protected CentralJobScheduler() { workStealingExecutors = new ConcurrentHashMap<>( 1 ); topLevelGroup = new TopLevelGroup(); pools = new ThreadPoolManager( topLevelGroup ); ThreadFactory threadFactory = new GroupedDaemonThreadFactory( Group.TASK_SCHEDULER, topLevelGroup ); scheduler = new TimeBasedTaskScheduler( Clocks.nanoClock(), pools ); // The scheduler thread runs at slightly elevated priority for timeliness, and is started in init(). schedulerThread = threadFactory.newThread( scheduler ); int priority = Thread.NORM_PRIORITY + 1; schedulerThread.setPriority( priority ); }
private ExecutorService createNewWorkStealingExecutor( Group group, int parallelism, boolean asyncMode ) { ForkJoinPool.ForkJoinWorkerThreadFactory factory = new GroupedDaemonThreadFactory( group, topLevelGroup ); return new ForkJoinPool( parallelism, factory, null, asyncMode ); }
ThreadPool( Group group, ThreadGroup parentThreadGroup ) { threadFactory = new GroupedDaemonThreadFactory( group, parentThreadGroup ); executor = group.buildExecutorService( threadFactory ); registry = new ConcurrentHashMap<>(); }
protected CentralJobScheduler() { workStealingExecutors = new ConcurrentHashMap<>( 1 ); topLevelGroup = new TopLevelGroup(); pools = new ThreadPoolManager( topLevelGroup ); ThreadFactory threadFactory = new GroupedDaemonThreadFactory( Group.TASK_SCHEDULER, topLevelGroup ); scheduler = new TimeBasedTaskScheduler( Clocks.nanoClock(), pools ); // The scheduler thread runs at slightly elevated priority for timeliness, and is started in init(). schedulerThread = threadFactory.newThread( scheduler ); int priority = Thread.NORM_PRIORITY + 1; schedulerThread.setPriority( priority ); }