Parallel and Asynchronous Programming with Streams and CompletableFuture by Venkat Subramaniam
Vložit
- čas přidán 11. 09. 2024
- Subscribe to Devoxx on CZcams @ bit.ly/devoxx-...
Like Devoxx on Facebook @ / devoxxcom
Follow Devoxx on Twitter @ / devoxx
Java 8 makes it relatively easy to program with parallel streams and to implement asynchronous tasks using CompletableFuture. When someone says it’s easy, cautious programmers ask “What’s the catch?” Well, of course, that’s one of the major topic we’ll address in this deep dive session. We will start with a fast introduction to parallel and asynchronous programming with Java 8 and quickly delve into the gotchas, when to use these facilities, when to avoid them, and how and where to put them to good use.
Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., creator of agilelearner.com, and an instructional professor at the University of Houston. He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is a regularly-invited speaker at several international conferences. Venkat helps his clients effectively apply and succeed with sustainable agile practices on their software projects.
Venkat is a (co)author of multiple technical books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer. You can find a list of his books at agiledeveloper.com. You can reach him by email at venkats@agiledeveloper.com or on twitter at @venkat_s
Best statement in this video: "If you want to run code really fast and you don't care about result being really wrong then you should go back and program in C++".
I am simple man. I see Venkat I press like
Perfection is Venkat ! What a passionate teacher... Really makes me want to improve my programming and thinking skills. Venkat turns coding into some sort of performance art like music... Its like watching a composer conducting a symphony.
This is a comprehensive guide to understand parallel and asynchronous programming with Stream APIs
Venkat, I've watched several of your presentations, and I feel that I should say that you are one of the best out there. Your presentations are exhaustive but succinct, effective, and compelling.
*Venkat is a real Java, Scala, Groovy Boss* 👑
And Kotlin
@@PatrickCornelien and . net
incomplete index:
Parallel streams:
12:30 Structure of concurrent vs sequential code
// begging error prone as lost comment
14:00 Sequential()
16:30 & 20:30 Parallel() vs Sequential()
18:00 observing threads
// end error prone
22:20 order of execution (forEachOrdered())
24:00 Controlling the order
28:10 parallel and Filtering
30:00 reduce
39:00 parallel and reduce
42:20 Parallel stream
50:50 How many threads & where are things running
54:50 work stealing
56:45 Change n of threads at JVM
1:02:55 Changing to a new ThreadPool programmatically
1:07:30 Parallel != fast
1:18:00 Find1st vs findAny
1:23:00 parallel and resource utilization efficiency
Completable Future:
1:28:00 Async execution
1:29:00 callbacks; promise
1:33:55 Java CompletableFuture == JS promise
1:37:30 supplyAsync(() -> {}); get() vs getNow(default)
1:41:30 thenAccept(data -> {})
1:44:00 speed of caller (main thread); that determines who runs the code
1:46:00 ForkJoinPool supplyAsync(() -> {}, pool1), still main might steal work.
1:47:34 Async vs no Async, choose thread to run. thenAcceptAsync(fn, pool2)
1:52:10 creating pipelines
1:55:50 error channel/exceptions
Awesome
You deserve a beer 🍺 🙂
This is simply excellent! Easy to understand, well-structured, put in simple way and hilarious at times. Thank You sir!
Truly a java master , efficient lecturer 👍.. Everything to the point..
I also saw another video of this guy , compared to other horrible and outdated java stuff on CZcams, this is far beyond awesome. 10 out of 10 would recommend.
How can he manage to: talk, read error, find typo, and fix it without interrupting? 25:03 :) I love all his talks
just started to scroll comments to see if anyone else noticed it :D inhuman!
multi-threading...
@@juanmf Is it multi-tasking or multi-threaded or multi-programming :-) how does he context switch ;-)
reading books about java not understanding anything -> come back to this guy's presentations - everything makes sense
I love the way he present not only in this video but all his presentation.
He holds us through is wit and presentation.
Wow, amazing presentation. It would be an amazing opportunity to work with Venkat
damn !!! this guy is awesome
Fantastic talk, as usual with Venkat Subramanian !!
Wonderful way of delivery and easy to understand
I wish my university professors were this good 😁
Another brilliant presentation from Venkat.
I love Venkat presentations, but my eyes simply couldn't watch this with screen constantly micro-jumping.. Is there anywhere the same talk with better video quality?
One word. Superb.
Great presentation, especially regarding number of threads to use.
you are AWESOME!!!
Super sir
Tq venkat
amazing speech, content and examples.. excellant
1:25 CompletableFuture
What is this Sleep.sleep? Is it some custom implementation for Thread.sleep? I don't get it in Java API
Deepak Antil you've got it right, hidden implementation of standard sleep operation.
Beautiful... Can we have shorter session on the same.. ? I really appreciate you sir for the great work. But need shorter session.
at 2:10:16, venkat mention about completeOnTimeout.. but this API is available since Java 9 not 8
We need more of this for Java noobs like me 💜😍
You are full on code, Thanks for this... :)
Nice explanation of stream api
Where can I download the notes for this? Usually he has them at his website under agiledeveloper.com/downloads.html but doesn't seem to have this particular talk included.
Perfect..... very valuable info...... Thanks :)
Beyond high sense
Excellent!
Thank you
The reason why he is not getting performance change at 1:11 is because he is creating thread pool with different size but eventually using only one thread always from the pool :-) and i think same the the problem @ 1:05. He is using only one thread out of ForkJoinPool so 50/100 does not matter
I don't understand the underlying implementations completely so I'm not certain but where does the code say that the threads in the pool has different sizes? And where does it say that only one thread is being used from the pool...?? Maybe under the hood the language is doing what you said so that's what he is demonstrating just that... But I couldn't understand or see how he manually created a pool of different sized threads then only used one. Also your timestamps are off by a unit. Interesting idea nonetheless... Would like to know more about your reasoning.
How to find out the value of blockingfactor for an app? Can it be computed?
1:25:25
Which ide he is using ? i am asking because ide is showing output instantly
Mian Muhammad Zubair textmate
Okay textmate is only for mac i guess thx for reply
Nice talking.
He always pronounces years as ears😁
That's how we pronounce it in India he he... Also same goes for hours(ours) , is(ease) etc etc...