Java ExecutorService - Part 2

  Рет қаралды 21,215

Jakob Jenkov

Jakob Jenkov

Күн бұрын

Пікірлер: 44
@garamburito
@garamburito 3 жыл бұрын
It was a very good and clear explanation about the configuration of numbers of threads, thank you!
@JakobJenkov
@JakobJenkov 3 жыл бұрын
Good - glad you think so ! :-)
@sharadyadav9630
@sharadyadav9630 3 жыл бұрын
Great .Please continue your work.
@JakobJenkov
@JakobJenkov 3 жыл бұрын
Thank you, I will - although I have limited time to make these videos, unfortunately! :-)
@JoaoDias-xe2gg
@JoaoDias-xe2gg 3 жыл бұрын
amazing content, I really enjoy your videos, thank you so much!
@JakobJenkov
@JakobJenkov 3 жыл бұрын
Thanks - and your are welcome :-)
@LucAlucard1
@LucAlucard1 10 ай бұрын
Does Java use parallelism when we use Threads automatically? For example, If I've 4 CPU cores, if I create 4 threads, will they be executed equally among the existent CPUs?
@JakobJenkov
@JakobJenkov 10 ай бұрын
Java's standard threads (now called Platform Threads) are OS threads - so it is up to the OS to decide where your threads run. In many cases your threads will run on multiple CPU cores. But if the computer is very busy on all CPU cores with other tasks, your threads might end up running on the same core, or some threads on the same core at least.
@LucAlucard1
@LucAlucard1 10 ай бұрын
@@JakobJenkov thanks for replying teacher! I recently saw your channel and it’s being grate to see all videos. They are quite well explained and detailed!
@achuthiruku4458
@achuthiruku4458 3 жыл бұрын
Very good video with clear explanation.
@JakobJenkov
@JakobJenkov 3 жыл бұрын
Glad you liked it! :-)
@alicanklc6539
@alicanklc6539 8 ай бұрын
Great explanations also Jakob can you include in which situation(s) do we need to use which of them.
@hareeshjp
@hareeshjp 3 жыл бұрын
Thank you it was very clear crystal video. Thank you very much Jakob.
@JakobJenkov
@JakobJenkov 3 жыл бұрын
You are welcome! :-)
@MateuszNaKodach
@MateuszNaKodach 3 жыл бұрын
Thanks for the amazing video :) I have a question for concurrency. If I have for example 8 CPUs you said that, I can create thread pool with 8 threads and execute tasks in the same time. But what about others programs running on the same machine? Whats their impact? Our JVM is not only thing, we have operating system etc.
@JakobJenkov
@JakobJenkov 3 жыл бұрын
That is true - then JVM is often not the only process running on the machine. To be sure you would have to measure performance with different number of threads.
@Minimingus
@Minimingus 3 жыл бұрын
great content! any chance to do something similar for the CompletableFuture api? there are many tutorials but none of them are in depth or show practical, real life examples
@JakobJenkov
@JakobJenkov 3 жыл бұрын
I might - but it all depends on how much time I have available - and at the moment I am really busy...
@LucAlucard1
@LucAlucard1 10 ай бұрын
In case of cancelling it, do we know where it will be stopped? I mean, in previous videos from this exceptional series of multithreading and parallelism, it was sometimes we need to add a flag like "wasCancelled" to stop it in a specific point where it's "safe" for our case. Should we do the same for Future and Callable?
@JakobJenkov
@JakobJenkov 10 ай бұрын
As far as I remember, if a task is started - it will finish. I cannot remember if the Java ExecutorService sends a cancel signal to the task. But if a task has been queued in the ExecutorService but not yet started, it will not be started at all.
@LucAlucard1
@LucAlucard1 10 ай бұрын
@@JakobJenkov thanks for explaining, teacher!
@andrewnesbitt2593
@andrewnesbitt2593 Жыл бұрын
Brilliant. Thank you.
@JakobJenkov
@JakobJenkov Жыл бұрын
You are welcome ! :-)
@bnnr4883
@bnnr4883 9 ай бұрын
is that Thread concept is interduce by you in java 😉? The why you are explaining like you are the founder of thread its really very clear thank you so much for this video's
@JakobJenkov
@JakobJenkov 9 ай бұрын
Thank you !! 😁 ... No, I am not the founder of threads in Java... 😁 ... but I have been explaining Java related concepts since 2006, so I had a but of practice 😊
@rameshk2338
@rameshk2338 Жыл бұрын
Hi boss, Can you make videos on completable future in java
@JakobJenkov
@JakobJenkov Жыл бұрын
Hmm.... I might - thank you for the suggestion! :-)
@JoseLopez-wh7xe
@JoseLopez-wh7xe Жыл бұрын
Amazing! 😊
@JakobJenkov
@JakobJenkov Жыл бұрын
Thanks ! :-)
@BoomLooBoom
@BoomLooBoom 3 жыл бұрын
The documentation says that ExecutorService#shutdown() does not wait for previously submitted tasks to complete execution docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorService.html#shutdown()
@JakobJenkov
@JakobJenkov 3 жыл бұрын
The method shutdown() does not wait for the ExecutorService to fully shut down - before exiting the shutdown() method. However, the ExecutorService will not be fully shutdown until all submitted tasks have been executed. In other words, the shutdown process continues asynchronously. To wait for all these tasks to finish executing, use awaitTermination(). I apologize if the video is a bit unclear here.
@fadidasus6329
@fadidasus6329 3 жыл бұрын
@@JakobJenkov thanks for the great content and crystal clear expectations. I just want to be sure that I understood the comment here correctly, so, does the shutdown method block the main thread until all tasks have completed, or it waits for all tasks to be completed and then shutdown the executor service without blocking the main thread ? Thanks in advance
@shamilibrahimov3898
@shamilibrahimov3898 Жыл бұрын
shutdown() itself does not block the main thread, but you can use awaitTermination() if you want to block and wait for the tasks to complete and the ExecutorService to shut down.@@fadidasus6329
@leonardschmidt1864
@leonardschmidt1864 Жыл бұрын
can you make a video for the forkjoinpool in java :)
@JakobJenkov
@JakobJenkov Жыл бұрын
I have planned to do so 😊 Until then, you can start with the textual version of my ForkAndJoinPool tutorial, here jenkov.com/tutorials/java-util-concurrent/java-fork-and-join-forkjoinpool.html
@menoktaokan
@menoktaokan 3 жыл бұрын
Thank you for the video.
@JakobJenkov
@JakobJenkov 3 жыл бұрын
You are most welcome :-)
@victorb9486
@victorb9486 3 жыл бұрын
Is it possible for you to share the code completely? For tests it my self,bassically
@JakobJenkov
@JakobJenkov 3 жыл бұрын
Not at this point in time - but maybe for future videos!
@victorb9486
@victorb9486 3 жыл бұрын
@@JakobJenkov ok, thanks for answer me
@mdshafi7043
@mdshafi7043 3 жыл бұрын
Assalamualikum.Can you please make a video or 2 on deadlock situation in java multithreading and how to handle them
@JakobJenkov
@JakobJenkov 3 жыл бұрын
I can - when I find the time to make it :-)
@hungnguyenngoc3069
@hungnguyenngoc3069 Жыл бұрын
I need subtitle, thanks
Java ExecutorService - Part 1
20:56
Jakob Jenkov
Рет қаралды 56 М.
Race Conditions in Java Multithreading
22:39
Jakob Jenkov
Рет қаралды 34 М.
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 21 МЛН
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 6 МЛН
Smart Sigma Kid #funny #sigma
00:33
CRAZY GREAPA
Рет қаралды 10 МЛН
Thread Pools in Java
18:04
Jakob Jenkov
Рет қаралды 70 М.
Compare and Swap in Java
24:21
Jakob Jenkov
Рет қаралды 17 М.
Java ExecutorService - Part 1 - Introduction
10:12
Defog Tech
Рет қаралды 423 М.
Java Lock
28:51
Jakob Jenkov
Рет қаралды 47 М.
Java Threads - Creating, starting and stopping threads in Java
17:14
Learn Java Executor Framework in 14 minutes
14:25
Craft Of Programming
Рет қаралды 7 М.
Concurrency vs Parallelism
9:29
Jakob Jenkov
Рет қаралды 68 М.
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 21 МЛН