Download presentation
Presentation is loading. Please wait.
Published byPhillip Fleming Modified over 9 years ago
1
Thread Synchronization including Mutual Exclusion In Java synchronized keyword Monitor or Lock with conditions Semaphore
2
Semaphores Semaphore S = 3; P(S) { wait until S>0; S=S-1; } V(S) { S=S+1; }
3
Semaphores for Mutual Exclusion Thread 1 P(S) Access Shared Data V(S) Thread 2 P(S) Access Shared Data V(S) Semaphore S = 1; Shared Data
4
Semaphores for Synchronization Thread 1 P(S) Print “AAAAA” Thread 2 Print “BBBBB” V(S) Semaphore S = 0;
5
Semaphores for Synchronization Thread 1 P(S) Print “AAAAA” Thread 2 Print “BBBBB” V(S) Semaphore S = 0;
6
Semaphores in Java Semaphore s = new Semaphore(initCount); s.acquire(); or s.acquire(count); s.release(); or s.release(count);
7
Examples
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.