Skip to content

Instantly share code, notes, and snippets.

@aerodame
Created February 19, 2025 18:46
Show Gist options
  • Save aerodame/61179e942437da8224ec497f44f33fcf to your computer and use it in GitHub Desktop.
Save aerodame/61179e942437da8224ec497f44f33fcf to your computer and use it in GitHub Desktop.
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