Created
February 19, 2025 18:46
-
-
Save aerodame/61179e942437da8224ec497f44f33fcf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class B extends Thread { | |
private Semaphore[] resource; | |
public B(Semaphore[] m) { | |
resource = m; | |
} | |
public void run() { | |
System.out.println("B started"); | |
synchronized (resource[3]) { | |
System.out.println("--B locks rsc 3"); | |
synchronized (resource[0]) { | |
System.out.println("--B locks rsc 0"); | |
synchronized (resource[2]) { | |
System.out.println("--B locks rsc 2"); | |
} | |
} | |
} | |
System.out.println("B finished"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment