Welcome back to the Multithreading in Java Series!
In this episode, we dive deep into one of the most elegant and powerful synchronization tools in Java: Semaphores.
Timelines:
00:00 - Intro & Agenda
02:46 - Analogy for Semaphores
03:33 - Technical terms used in Semaphores
05:53 - Code Example
09:22 - Semaphore with 0 permits
11:50 - How to check available permits?
13:52 - Are Semaphores Thread Safe?
14:28 - Formal Definition and Properties
15:48 - Homework Problem
16:50 - Hints and Ending Notes
👨🏫 What’s covered in this video:
What are Semaphores? (Explained with an easy real-life analogy)
How Semaphores handle concurrency
Why there are no race conditions when using them correctly
Formal definition and key properties of a Semaphore
🧠 Homework Challenge at the end:
Try solving the Ping-Pong Print Problem using Semaphores!
Two threads: one prints “Ping”, the other prints “Pong” — and they alternate.
✨ This problem will help reinforce your understanding of Semaphores before we solve it together in the next video.
📚 Catch up on previous topics:
Threads, Runnable, synchronized
wait()/notify()
Java Memory Model (volatile, happens-before)
Real-world multithreading problems like Odd-Even and Print 1–N using N threads
📌 Subscribe and turn on the bell 🔔 so you don’t miss the Ping-Pong solution and future threading challenges!
#Java #Multithreading #Semaphores #JavaConcurrency #Threads #JavaThreads #JavaInterview #BitsOfCode
In questa pagina del sito puoi guardare il video online #6 Mastering Semaphores in Java Multithreading 🔐 | Understand Easily + Homework Challenge! della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Bits of Code by Anand 01 giugno 2025, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,120 volte e gli è piaciuto 49 spettatori. Buona visione!