use of java.util.concurrent.locks.LockSupport in project hazelcast-jet by hazelcast.
the class TaskletExecutionService method submitCooperativeTasklets.
private void submitCooperativeTasklets(ExecutionTracker executionTracker, ClassLoader jobClassLoader, List<Tasklet> tasklets) {
ensureThreadsStarted();
final List<TaskletTracker>[] trackersByThread = new List[cooperativeWorkers.length];
Arrays.setAll(trackersByThread, i -> new ArrayList());
for (Tasklet t : tasklets) {
t.init();
trackersByThread[cooperativeThreadIndex.getAndUpdate(i -> (i + 1) % trackersByThread.length)].add(new TaskletTracker(t, executionTracker, jobClassLoader));
}
for (int i = 0; i < trackersByThread.length; i++) {
cooperativeWorkers[i].trackers.addAll(trackersByThread[i]);
}
Arrays.stream(cooperativeThreadPool).forEach(LockSupport::unpark);
}
Aggregations