Java ExecutorService - Part 1

  Рет қаралды 56,638

Jakob Jenkov

Jakob Jenkov

Күн бұрын

Пікірлер: 61
@MoZaHo
@MoZaHo 2 жыл бұрын
Best description and video of the ExecuterService on the internet. Helped a great load. Thank you
@JakobJenkov
@JakobJenkov 2 жыл бұрын
Thank you very much for your kind words! :-) ... and for taking the time to tell me! :-)
@karthikgsarode900
@karthikgsarode900 Ай бұрын
Detailed, to the point explanation. Thanks a lot Jacob!
@JakobJenkov
@JakobJenkov Ай бұрын
You are welcome ! :-)
@fatihmehmetkose
@fatihmehmetkose 3 жыл бұрын
Thanks Jacob! this is the best explanation of ExecuterService and Callable I have seen...
@JakobJenkov
@JakobJenkov 3 жыл бұрын
Thank you! I am happy my video was helpful to you! Actually, the video is a re-recording of an old video about the Java ExectutorService which I felt could be improved. Seems like it was indeed an improvement from the old version :-)
@Dayakar-vi5dh
@Dayakar-vi5dh Ай бұрын
Thank you sir, For clear cut explanation.
@JakobJenkov
@JakobJenkov Ай бұрын
You are welcome ! :-)
@sumanshekhar8110
@sumanshekhar8110 4 ай бұрын
I think invokeAny() starts executing all the task in the Colection, and returns the o/p of the task which completed First. After this all the tasks are canceled. Btw thanks for the awesome explaination. We want more of your knowledge :p
@JakobJenkov
@JakobJenkov 4 ай бұрын
Thanks - and thanks for the input !! These constructs are sometimes a bit hard to get to know correctly 😊
@mdshafi7043
@mdshafi7043 3 жыл бұрын
Sir , Can you please make a video or 2 on deadlock situation in multithreading and how to handle them in java ? Your videos are very helpful.I understand multithreading well by watching your videos
@JakobJenkov
@JakobJenkov 3 жыл бұрын
Hmm... I probably could :-) ... I think I will get to that topic soon.
@Jagan3559
@Jagan3559 9 ай бұрын
It was very nicely put and easy to understand
@JakobJenkov
@JakobJenkov 9 ай бұрын
Thank you ! I am happy you feel like that ! :-)
@mouradlaraba
@mouradlaraba 3 жыл бұрын
Thnaks a lot sir your courses are very helpfull, you are very generous in sharing your knowledge with us thnaks a lot
@JakobJenkov
@JakobJenkov 3 жыл бұрын
You are most welcome! :-) ... I hope my videos help you!
@BtXFWkyZBtXFWkyZ
@BtXFWkyZBtXFWkyZ 3 жыл бұрын
Reminder is set, thanks for the content sir
@JakobJenkov
@JakobJenkov 3 жыл бұрын
Always welcome :-)
@ahmetbcakici
@ahmetbcakici Жыл бұрын
Thanks for the content! It ıs really so useful and easy to understand.
@JakobJenkov
@JakobJenkov Жыл бұрын
Thanks! I am glad you feel that way ! :-)
@roman_mf
@roman_mf 2 жыл бұрын
Hi Jakob, thanks for another excellent explanation. I have a question about invokeAny() - you say that it executes one task, but you also that the one that executes fastest gets to send its return value. How does "fastest" work in this case? Do all tasks in a collection run concurrently and they just race for who finishes execution first? invokeAny sounds almost like it just picks one task and has some logic of a failure in execution, like a timeout.
@JakobJenkov
@JakobJenkov 2 жыл бұрын
The ExecutorService will attempt to start as many of the tasks as possible, and whatever task finishes first has its result returned. I don't know the exact logic used internally, unfortunately. I have never needed invokeAny() myself.
@garimadhanania1853
@garimadhanania1853 7 ай бұрын
quick clarification: in the invokeany() call, it could happen that few of the tasks were executing and because of one of them completed and returned the result, the others were aborted? I mean there could be multiple tasks being executed on the different threads right? If only one task is run, it might take a long time to return and that defeats the purpose of using invokeAny() right?
@JakobJenkov
@JakobJenkov 7 ай бұрын
Yes, more than one task might get executed, but invokeAny() returns as soon as one task has finished executing. The motivation to use invokeAny() is to push N tasks out to N CPU cores, to get one of the tasks to finish as fast as possible.
@devalshah69
@devalshah69 9 ай бұрын
Hey Jakob thanks you for such a detailed video explanation of the Java concurrency. I am not able to find this codes of Executor services in your github repo, is there anyway to get this implementations code?
@JakobJenkov
@JakobJenkov 9 ай бұрын
The ExecutorServive is part of standard Java... so if you have Java, you also have the ExecutorService implementation 😊
@LuneAgent
@LuneAgent 3 жыл бұрын
Great Scott! We can get a result back from the future!
@JakobJenkov
@JakobJenkov 3 жыл бұрын
:-) ... well, not to ruin your pun - but it's probably more correct to say that we wait for the Future to become the present and then we obtain the result ;-)
@LuneAgent
@LuneAgent 3 жыл бұрын
@@JakobJenkov Yeah, I know how it works, but it sounds great when described that way :)
@smitmandavia5044
@smitmandavia5044 10 ай бұрын
Thanks a lot for the video and other videos in this playlist. They are really useful. I think one small suggestion is to clarify that how is this different than thread Pools (explained in previous video). I guess Thread pool was our own simple implementation whereas this is an inbuilt and more nuanced version of it. Please correct me if I am wrong or missed anything.
@JakobJenkov
@JakobJenkov 9 ай бұрын
The Java ExecutorService is very similar to a thread pool. Some of them are implemented as thread pools, but some of them are a bit more advanced, like the ForkAndJoinPool .
@강승윤-n4w
@강승윤-n4w 3 жыл бұрын
I love your tutorial web site and also like this video ! It's really helpful. Thanks a lot !
@JakobJenkov
@JakobJenkov 3 жыл бұрын
You are welcome! Glad you like it all! :-)
@sam_paul
@sam_paul 3 жыл бұрын
Very well explained.. Thank you very much !
@JakobJenkov
@JakobJenkov 3 жыл бұрын
You are welcome! :-)
@garimadhanania1853
@garimadhanania1853 7 ай бұрын
great content as always!
@JakobJenkov
@JakobJenkov 7 ай бұрын
Thank you !! 😊😊😊
@affeine9267
@affeine9267 Жыл бұрын
Why do we have multiple ThreadPools inside the ExecutorService ? We still can specify number of Threads that ThreadPool executes so why do we need more than one ThreadPool ?
@JakobJenkov
@JakobJenkov Жыл бұрын
There can be different kinds of implementations of the ExecutorService interface, meaning different implementations of thread pools that behave differently.
@csabadanyiko6096
@csabadanyiko6096 2 жыл бұрын
I really like your videos, great explanation for complex topics. I have one question. For invokeAll() you created a List then you cast it to Collection. Why didn't you just define it as Collection in the first place, is there a particular reason?
@JakobJenkov
@JakobJenkov 2 жыл бұрын
You could probably have created it as a Collection immediately. Sometimes I do stuff in the videos you would not do normally, just to make it more clear what is going on :-)
@pv2930
@pv2930 2 жыл бұрын
U deserve more subscribers 👍
@JakobJenkov
@JakobJenkov 2 жыл бұрын
Thank you :-)
@yumyumtales
@yumyumtales 2 жыл бұрын
Great Video❤❤❤
@JakobJenkov
@JakobJenkov 2 жыл бұрын
Thanks !! 😊
@tomasma4896
@tomasma4896 3 жыл бұрын
Thanks a lot for these videos. I am programming few years in Java but there is always something new I learn from your videos or from your web site. You definitely deserve more subscribers. Just an advice, maybe instead of old way anonymous classes you could use lambdas. But anyway good job and keep doing!
@JakobJenkov
@JakobJenkov 3 жыл бұрын
Hi Tomas, thank you for your kind words! :-) ... in this video I chose to use anonymous classes instead of lambdas to make it 100% clear that it is the Runnable / Callable interface that are being implemented! In my own code I would most likely use lambdas - but for instructional purposes I often simplify the code somewhat - to keep focus on the important parts. By the way, I also often learn something new when I write tutorials or make videos :-)
@RohanSharma-eh4kf
@RohanSharma-eh4kf 3 жыл бұрын
well i came to this video to understand the inner workings of these interfaces, is there any resources i can follow to understand how things work exactly?
@JakobJenkov
@JakobJenkov 3 жыл бұрын
I have another video about Thread Pools in Java which explains how to make your own thread pool like the ExecutorService, if you want that, or just want to learn how.
@AmeySambhare-ki6do
@AmeySambhare-ki6do Жыл бұрын
How did invokeAny return String? Should not it return future object of String?
@JakobJenkov
@JakobJenkov 10 ай бұрын
No. invokeAny will return the result of the first of your tasks that finishes. Since the ExecutorService doesn't know which task finishes first, it cannot know which Future object to return to you. Instead, it checks the Future objects internally for results, and as soon as one of the returns a result, that is what is returned.
@karthik8159
@karthik8159 2 жыл бұрын
Thank you.
@JakobJenkov
@JakobJenkov 2 жыл бұрын
You're welcome! :-)
@luuvanthao3679
@luuvanthao3679 3 жыл бұрын
greate
@JakobJenkov
@JakobJenkov 3 жыл бұрын
Thanks!
@minasalah8210
@minasalah8210 3 жыл бұрын
thank you
@JakobJenkov
@JakobJenkov 3 жыл бұрын
You are most welcome :-)
@manojnavinjamuri5867
@manojnavinjamuri5867 9 ай бұрын
please provide the code too
Java ExecutorService - Part 2
21:32
Jakob Jenkov
Рет қаралды 21 М.
Thread Pools in Java
18:04
Jakob Jenkov
Рет қаралды 70 М.
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 101 МЛН
Java BlockingQueue
17:48
Jakob Jenkov
Рет қаралды 41 М.
The Java Memory Model - The Basics
23:41
Jakob Jenkov
Рет қаралды 132 М.
Алексей Шипилёв - ForkJoinPool в Java 8
1:40:01
JPoint, Joker и JUG ru — Java-конференции
Рет қаралды 75 М.
Java Lock
28:51
Jakob Jenkov
Рет қаралды 47 М.
34. Thread Pools in Java | ThreadPoolExecutor Framework | Multithreading Part6
1:16:55
Concept && Coding - by Shrayansh
Рет қаралды 44 М.
Java ThreadLocal
14:36
Jakob Jenkov
Рет қаралды 37 М.
Deadlock in Java
17:48
Jakob Jenkov
Рет қаралды 23 М.
The Flaws of Inheritance
10:01
CodeAesthetic
Рет қаралды 970 М.
Новый iPhone 👍 @JaySharon
1:07
История одного вокалиста
Рет қаралды 3,1 МЛН
Наклейка SSD 💽
0:24
serg1us
Рет қаралды 426 М.
Better than Nokia ?..
0:14
NEXIDO EDITS
Рет қаралды 11 МЛН