Java ForkJoinPool execute() Method
The (ForkJoinTask<?> task) method arranges for asynchronous execution of given task specified as the parameter. The execute method is overloaded as execute (Runnable task) which is used to execute some command at some time in the future.
Task - the task to execute.
Does not return any value.
Example 1Test it Now
Thread[ForkJoinPool-1-worker-2,5,main] computing: 0 to 2 Thread[ForkJoinPool.commonPool-worker-3,5,main] computing: 5 to 7 Thread[ForkJoinPool.commonPool-worker-1,5,main] computing: 7 to 10 Thread[ForkJoinPool.commonPool-worker-3,5,main] computing: 0 to 2 Thread[ForkJoinPool.commonPool-worker-2,5,main] computing: 2 to 5 89 Thread[ForkJoinPool-1-worker-1,5,main] computing: 2 to 5
Example 2Test it Now
Common Pool Size before :0 Common Pool Size after :3