Java ForkJoin Pool # Java ForkJoin Pool 1. As it sounds, assist distribute work 2. From java 7 3. Based on Doug Lea's work 4. As it sounds, break to simpler tasks 1. Ideally, no worker thread idle 1. Threads steal work 5. Classes you use 1. ForkJoinPool 1. Implements ExecutorService 2. `ForkJoinPool = new ForkJoinPool(int parallelism)` 1. With no arg by default, numProcessors 3. Pool adjusts its size! (though you specified number) 1. Send ForkJoinPool Tasks with 1. Execute() - asynchronous 2. invoke() - sync awaits 3. submit() - Async get Future 2. ForkJoinTask 1. isDone() - true when complete 2. isCompletedNormally() - finished without exception 3. isCompletedAbnormally() - true cancelled / exception 6. How to use 1. Create `RecursiveTask` 2. Implement `compute()` in RecursiveTask to do your work 1. You can create additional tasks inside it, that
Software Engineering Best Practices, System Design, High Scale, Algorithms, Math, Programming Languages, Statistics, Machine Learning, Databases, Front Ends, Frameworks, Low Level Machine Structure, Papers and Computing, Computer Science Book Reviews - Everything!