Java ForkJoinPool
ฝัง
- เผยแพร่เมื่อ 22 ก.ค. 2024
- The Java ForkJoinPool helps you break down large tasks into smaller subtasks which can be executed in parallel using all, or some, of the CPU cores available in your computer. The Java ForkJoinPool thus helps you implement a fork and join type of work break down and parallelism.
The Java ForkJoinPool implements a work stealing algorithm which further helps utilize the CPU cores in your computer more efficiently. This work stealing algorithm is also explained in this Java ForkJoinPool tutorial.
Chapters:
0:00 Java ForkJoinPool introduction
1:18 Dividing tasks into subtasks
1:59 Fork and join process
3:48 Work stealing
7:27 Creating a ForkJoinPool code example
9:16 Submitting actions and tasks to a ForkJoinPool
10:56 RecursiveAction vs. RecursiveTask
11:55 RecursiveAction implementation example
18:28 RecursiveTask implementation example
22:32 Additional ForkJoinPool methods
X (Twitter): @jjenkov
LinkedIn: / jakob-jenkov-4a3a8
Java ForkJoinPool tutorial - text:
jenkov.com/tutorials/java-uti...
Java Concurrency tutorial - text:
jenkov.com/tutorials/java-con...
Java Concurrency video playlist:
• Java Concurrency and M...
Java Code Examples GitHub Repository:
github.com/jjenkov/java-examples - วิทยาศาสตร์และเทคโนโลยี
Jakob, you are purely a Legend. thanks a lot for the great explanations.
You are welcome! ... and thank you for your kind words! :-)
Lengend Jakob thanks for your explaination on java topics with deep insight
I've watched all of your videos on Concurrency and Multithreading, and they were incredibly informative. Thank you!
Thank you very much !!
I am happy you found them useful ! 😊
Thanks for this amazing playlist and clear explanations. Learned a lot from this!!!
You are very welcome! :-)
you make Java so much more interest! thank you!
Thanks a lot for your kind words !! 😊 ... and you are welcome !! 😊
Excellent tutorial, thank you very much!
You are welcome ! ... and thank you for your kind feedback! :-)
as always, you're the best.
thank you very much ^^
Thank you very much :-)
Thanks for the brilliant video, as always, clear and concise. I am still curious how does the async IO, CPU sharing look like. In the examples all the tasks were completed e2e. Is there a correct way of using IO, to make sure it's FJP compliant?
There is no special way of using IO required. If you use blocking IO from within an ForkJoinPool, the thread will be blocked until the IO call finishes. The ForkJoinPool might start up extra threads in that case, but I don't actually know.
@@JakobJenkov Thanks for the reply. I'll do some reasearch, as you point our yourself, there should be a way to get multiple tasks to share the same CPU.
if Java was the Kingdom Jakob would be the King
I am probably more of an ambassador ;-)
At 4:30, I thought that there was a single queue holding tasks. The executor choose a free thread to execute the next task in that single queue. In what executor, do we have a queue of tasks for each thread?
Some ExecutorService implementations have a single queue holding tasks internally. But the ForkJoinPool uses multiple queues.
should I learn operating system before learning java thread ?
No, that should not be necessary :-)
Best videos I've seen. I'm wondering why so low views !?
Thank you !!
You will have to ask TH-cam about the views... who knows how the TH-cam algorithms actually work... 🤷♂️