Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.ForkJoinPool; import java.util.concurrent.RecursiveTask; public class JavaForkJoingetAsyncModeExample1 extends RecursiveTask
{ @Override protected Integer compute() { try{ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } catch(Exception e) { } return 0; } public static void main(String[] args) { JavaForkJoingetAsyncModeExample1 left = new JavaForkJoingetAsyncModeExample1(); JavaForkJoingetAsyncModeExample1 right = new JavaForkJoingetAsyncModeExample1(); JavaForkJoingetAsyncModeExample1 finder = new JavaForkJoingetAsyncModeExample1(); ForkJoinPool pool = ForkJoinPool.commonPool(); pool.submit(left); pool.submit(right); pool.submit(finder); System.out.println("Finder :" + pool.invoke(finder) + " Active threads :" +pool.getActiveThreadCount() + " Left " +pool.invoke(left) + " Right "+ pool.invoke(right) ); System.out.println("Is pool use First-in-First-out Scheduling:" +pool.getAsyncMode()); } }
Output