Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; import java.util.List; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.RecursiveAction; class Taskl extends RecursiveAction { private long Load = 0; public Taskl(long Load) { this.Load = Load; } @Override protected void compute() { //if work is above the threshold, break tasks up into smaller tasks List
subtasks = new ArrayList
(); subtasks.addAll(createSubtasks()); for(RecursiveAction subtask : subtasks){ subtask.fork(); } } private List
createSubtasks() { List
subtasks =new ArrayList
(); Taskl subtask1 = new Taskl(this.Load / 2); Taskl subtask2 = new Taskl(this.Load / 2); Taskl subtask3 = new Taskl(this.Load / 2); subtasks.add(subtask1); subtasks.add(subtask2); subtasks.add(subtask3); return subtasks; } } public class GetUncaughtExceptionHandlerExample2 { public static void main(final String[] arguments) throws InterruptedException { int proc = Runtime.getRuntime().availableProcessors(); System.out.println("numbers of core available in your processor:" +proc); ForkJoinPool Pool = ForkJoinPool.commonPool(); int i= Pool.getPoolSize(); System.out.println("uncaught exception handler : " +Pool.getUncaughtExceptionHandler()); Taskl t = new Taskl(400); Pool.invoke(t); } }
Output