Загрузка...

#9 FizzBuzz with 4 Threads Explained | wait() vs Semaphore (Optimal Approach)

In this video, we solve the classic FizzBuzz multithreading problem using 4 threads in Java — where each thread is responsible for printing:

- Fizz (multiples of 3)
- Buzz (multiples of 5)
- FizzBuzz (multiples of 3 and 5)
- The number (otherwise)

Timelines:
00:00 - Intro & Agenda
00:18 - Problem Statement
02:32 - 1st Approach
04:05 - 1st Approach Code in IDE
11:43 - Why is this approach not optimal ?
14:18 - Intution of Optimal Approach using Semaphores
18:33 - Coding Optimal Approach in IDE
25:13 - Ending Notes and Next Video Agenda

We explore two approaches:
1. ✅ Using synchronized, wait() and notifyAll() — the traditional approach
2. ⚡ Using Semaphore — the optimized and efficient solution

You’ll learn:
- How thread synchronization works in Java
- The pitfalls of using wait() without notifyAll()
- Why semaphores provide better thread control
- How to avoid race conditions and deadlocks

🎓 Perfect for Java developers preparing for multithreading interviews or mastering concurrency concepts.

Github: https://github.com/AndyS12/Multithreading-in-Java/tree/main/Problems/src/MediumLevel/FooBar4Threads
LinkedIn: https://www.linkedin.com/in/anand-singh-sn/
Lecture Notes: https://drive.google.com/file/d/1WBTBsJd-3cq8ppho0B31_kr6GjDGovwr/view?usp=sharing

🔔 Don’t forget to like, subscribe, and share if you find this helpful!
#Java #Multithreading #Semaphores #ABCPrinterProblem #JavaInterview #ThreadSynchronization #JavaConcurrency #bitsofcode #bitsofcodeanand

Видео #9 FizzBuzz with 4 Threads Explained | wait() vs Semaphore (Optimal Approach) канала Bits of Code by Anand
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять