Thanks.. Instead of using employees. ParallelStream() we can also use employees.stream().parallel () , both of them are producing execution from parallel stream.
At 1:27 you said that sequential stream uses multiple threads but single core, but at 8:27 you can see only 1 thread is used by sequential stream. Can you please explain about this more ?
Awesome video. I come to know a lot of thing from this video. But here is a question, what if you call parallel stream first and then normal stream in the same program. The execution time shows otherwise .
@@Javatechie please specify how it work. if parallel processing is done first and after sequential stream then parallel is taking very much time than sequential.
Hey, Good video tutorials, but can you describe the pros and cons of using serial and parallel streams. It will be good if you can also say when to use these streams and why.
In begin I already mentioned Whenever you doesn't care for order of execution you should go for pareallstrem for example retrieve data from DB But it's always recommend to use write operation using parallstream if your data associated with other dependant entity or model
What happens when for certain code one's output will be input for next code to be executed . Even though multiple threads which is equivalent to multiple cores it has to be a serial execution.
Thank you so much sir! A very useful video❤. I need one help. In my case the execution time for parallel stream is more than that of normal stream. Could you please help me here with the reasoning?
I want to see the results by swapping code position..like firstly i will print parallel stream code block followed by normal stream and then see the difference
Hii... I have 3 queried need to run asyn....and need to wait for the results to store in list.... Then after 3 tasks done... I need to proceed further running the remaining code.... In this scenario...could anyone suggest which is better to use... I tried executor service...but it is going sync...not waiting for the threads to complete.... Thanks in advance
Could someone be so kind to explain me why at my computer, Plain stream took time : 3 but Parallel stream took time : 6. Parallel stream took more time than Plain stream.
example does not seems to be correct, just flip the code and use parallel stream first and then use sequential stream you will see the sequential one takes less time than parallel one.
Using all CPU cores is not advisable and it's noticed CPU usage reaches more than threshold. For personal RND this is ok but not on Production environment. Example to calculate average using parallelstream is not making any sense.
* Code is not formatted correctly, inconsistent spaces * One per line, every (.) and operation should come to the next line * Use `Instant` java.time class for start and end and use `Duration` to measure time between them (I know you are not aiming for these things in this example, this is for new developers)