Тёмный

Thread Congestion in Java 

Jakob Jenkov
Подписаться 40 тыс.
Просмотров 8 тыс.
50% 1

Thread congestion can occur when two or more threads are trying to access the same, guarded data structure at the same time. By "guarded" I mean that the data structure is guarded using synchronized blocks or a concurrent data structure (Lock, BlockingQueue etc.) so that the data structure is thread safe. The resulting thread congestion means that the threads trying to access the shared data structure are spending a high amount of time waiting in line to access the data structure - wasting valuable execution time on waiting.
Chapters:
0:00 Thread congestion introduction
1:40 Thread congestion wastes thread execution time
2:22 Thread congestion alleviation solutions
3:05 Work stealing improvement
3:58 Thread congestion code examples
Thread Congestion in Java - Tutorial - Text:
jenkov.com/tutorials/java-con...
Java Concurrency Tutorial - Text:
jenkov.com/tutorials/java-con...
Java Concurrency Video Playlist:
• Java Concurrency and M...
Java Thread Visibility is covered in:
• The Java Memory Model ...
• Java Happens Before Gu...
• Java Synchronized - Th...
• Java Volatile
• CPU Cache Coherence + ...

Наука

Опубликовано:

 

28 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 44   
@mathiassintal2237
@mathiassintal2237 2 года назад
I watched all of your videos in this playlist and almost everything is very simple explained and easily understandable. Thank you so much for the high quality content and your very good teaching! Much love, I really appreciate your work!
@JakobJenkov
@JakobJenkov 2 года назад
You are welcome! Glad it was helpful and easy to understand! I put a lot of effort into making the topics easy to understand, so I am always happy whenever a person experience that it was :-)
@garimadhanania1853
@garimadhanania1853 2 месяца назад
also a tip: it would have been good to see the time difference in performance for the 2 examples discussed, that way we can say that the 1st example takes more time to consume because of the blocking
@menchomenchev8973
@menchomenchev8973 2 года назад
Thank you for all the effort you put in Jakob!
@JakobJenkov
@JakobJenkov 2 года назад
You are welcome! And thank you for telling me! :-)
@DJcRuT000
@DJcRuT000 2 года назад
Thank you for great explanation and adding illustrations to your videos it really helps to understand!
@JakobJenkov
@JakobJenkov 2 года назад
You are welcome! :-) I am happy you liked them!
@gracewannemacher
@gracewannemacher 2 года назад
Hi Jakob, I watched all your videos in this playlist and it really helped me as someone new to Java. These must have taken a lot of time. Thank you for making these! And let us know if you plan on opening a Patreon again.
@JakobJenkov
@JakobJenkov 2 года назад
Hi Grace, thank you for letting me know! :-) I did have a Patreon account at some point, but only 2 people ever signed up, and they didn't remain signed up for long, so I ended up shutting it down. Developers are notorious for expecting everything "for free" ;-)
@user-kf8vn6pn5l
@user-kf8vn6pn5l 3 месяца назад
Thank you! Was very helpful! Does keepRunning need to be atomic?
@rakhmankobek5703
@rakhmankobek5703 2 года назад
Thank you very much! Really great video.
@JakobJenkov
@JakobJenkov 2 года назад
Thanks ! Glad you liked it! :-)
@kafychannel
@kafychannel Год назад
great tutorials thank you!
@JakobJenkov
@JakobJenkov Год назад
You are welcome! :-)
@mostinho7
@mostinho7 2 года назад
Done thanks great video Thread congestion due to lock contention, as you increase consumer threads throughout will increase but eventually decrease due to congestion Solution give each thread its own data structure or use lock free DS
@JakobJenkov
@JakobJenkov 2 года назад
When 2 threads each increment the same counter 1 million times - then the final total number of increments will be 2 million - but only the last thread to reach 1 million increments will see the final total of 2 million increments when it checks the total (after making its own 1 million increments).
@edward69951
@edward69951 2 года назад
Very good tutorial, really appreciated it.
@JakobJenkov
@JakobJenkov 2 года назад
Thank you ! :-)
@jasonadventure2265
@jasonadventure2265 2 года назад
Great Thanks for this tutorial, really helpful.
@JakobJenkov
@JakobJenkov 2 года назад
You are welcome ! :-)
@kavishkamadhudhan1943
@kavishkamadhudhan1943 2 года назад
Thank you very much for this amazing tutorial and l learned lot from this. Also, It's easily understandable.♥
@JakobJenkov
@JakobJenkov 2 года назад
Thank you! I am happy to hear that! :-)
@AbiSaran4413
@AbiSaran4413 2 года назад
Nice tutorial, thanks. Please upload atleast one video per week.
@JakobJenkov
@JakobJenkov 2 года назад
Thanks! ... I wish I had the time to upload tutorials that often - but unfortunately I don't :-/
@The2araf
@The2araf 2 года назад
Thank you very much!
@JakobJenkov
@JakobJenkov 2 года назад
You are welcome!
@yangfanzheng4323
@yangfanzheng4323 2 года назад
you don't actually need to synchronize the local variable in main method. In JMM, if thread A run action a before it starts the Thread B while b is the first action in Thread B, then the hb(a, b)
@yangfanzheng4323
@yangfanzheng4323 2 года назад
A call to start() on a thread happens-before any actions in the started thread.
@Rhemaxus
@Rhemaxus 2 года назад
Спасибо!
@JakobJenkov
@JakobJenkov 2 года назад
Hi Rhemaxus, thank you for the tip ! :-) ... I did not realize there was a tip attached to this comment until today! Thanks again! :-)
@garimadhanania1853
@garimadhanania1853 2 месяца назад
question: lets say there are two cores and one thread running on each core, so basically 2 threads running in parallel lets say there are two tasks in the blocking queue if thread1 and thread2 parallelly try to access the queue to pick up the tasks, one of them gets blocked and say thread1 is able to pick up task1, now only when thread1 has stopped accessing the queue can thread2 read task2 from the queue? Both it could happent that thread1 started executing task1 and just after that thread2 picked and started executing task2, and now both threads are running parallelly? Long story short, the blocking is only for accessing the queue to pick up tasks and not to execute the tasks themselves right?
@JakobJenkov
@JakobJenkov 2 месяца назад
Yes, the BlockingQueue only guards access to the queue itself. It does not affect what the threads do with the objects taken from the queue.
@amalangelraj
@amalangelraj 2 года назад
Your java se tutorial site is not working, could you please make it up and running
@JakobJenkov
@JakobJenkov 2 года назад
The old server has become unstable. I have been in the process of moving to cloud infrastructure, so going forward it should all get much more stable over time!
@amalangelraj
@amalangelraj 2 года назад
@@JakobJenkov i can't beleive that my role model and (guru like) good soul is replying to me! Thank you for your time. I want guidance from you, on how to proceed after completing java se tutorial. I wanted to become a good java developer! Shall i start studying spring tutorial or jsp, servlets and ejb? Im learning a little bit of basics of python since i heard that there is jython (java + python) If you could help me by giving a road map to become a good developer, it would be a great support for me to get a job. Please help me to learn development, so that i can reduce burden of my family especially i wanna pay back my mother who supported me in my tough times!
@amalangelraj
@amalangelraj 2 года назад
@@JakobJenkov is there any cloud infrastructure that is free to learn/use for learning java development?
@cherrejim
@cherrejim 2 года назад
Thanks for your job. I'd like a video about ForkJoinPool... If you want ideas 💡
@JakobJenkov
@JakobJenkov 2 года назад
Feedback and ideas are always welcome! :-) I've had some months with too many other things going on - so not enough time to make videos. But I think I will get some done again soon. Got a mixed bag of topics I have material enough to make videos about. Regarding the ForkAndJoinPool - I actually have a textual tutorial on my tutorial website you can start with (until I get around to making a video): jenkov.com/tutorials/java-util-concurrent/java-fork-and-join-forkjoinpool.html
@stalliow404
@stalliow404 2 года назад
Where can we find the source code
@JakobJenkov
@JakobJenkov 2 года назад
On GitHub - here: github.com/jjenkov/java-examples/tree/main/src/main/java/com/jenkov/java/concurrency/threadcongestion
@TRUTHF0RCE
@TRUTHF0RCE 2 года назад
Hi. Your website is down, just sayin
@JakobJenkov
@JakobJenkov 2 года назад
Had unstable server, and DNS issues lately...
@alexop5919
@alexop5919 2 года назад
Next Project Loom?
@JakobJenkov
@JakobJenkov 2 года назад
Project Loom is not yet finalized, as far as I know.
Далее
Thread Signaling in Java
23:26
Просмотров 10 тыс.
Deadlock Prevention in Java
17:49
Просмотров 14 тыс.
Игровой Комп с Авито за 4500р
01:00
Он тоже из IKEA 🙀
00:10
Просмотров 408 тыс.
Single-threaded and Same-threaded designs
18:01
Просмотров 11 тыс.
Java Lock
28:51
Просмотров 43 тыс.
Race Conditions in Java Multithreading
22:39
Просмотров 31 тыс.
Compare and Swap in Java
24:21
Просмотров 15 тыс.
FANG Interview Question | Process vs Thread
3:51
Просмотров 284 тыс.
Java BlockingQueue
17:48
Просмотров 38 тыс.
Дорогие компы БЕСПОЛЕЗНЫ?
1:00
Просмотров 738 тыс.