Presentation is loading. Please wait.

Presentation is loading. Please wait.

Thread Synchronization including Mutual Exclusion In Java synchronized keyword Monitor or Lock with conditions Semaphore.

Similar presentations


Presentation on theme: "Thread Synchronization including Mutual Exclusion In Java synchronized keyword Monitor or Lock with conditions Semaphore."— Presentation transcript:

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


Download ppt "Thread Synchronization including Mutual Exclusion In Java synchronized keyword Monitor or Lock with conditions Semaphore."

Similar presentations


Ads by Google