Skip to content

Instantly share code, notes, and snippets.

@aerodame
Created February 19, 2025 18:46
Show Gist options
  • Save aerodame/7b7968c9269344c62ff840f866fe30b3 to your computer and use it in GitHub Desktop.
Save aerodame/7b7968c9269344c62ff840f866fe30b3 to your computer and use it in GitHub Desktop.
private class A extends Thread {
private Semaphore[] resource;
public A(Semaphore[] m) {
resource = m;
}
public void run( ) {
System.out.println( "A started" );
synchronized ( resource[1] ) {
System.out.println( "--A locks rsc 1" );
synchronized ( resource[0] ) {
System.out.println( "--A locks rsc 0" );
}
}
System.out.println( "A finished" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment