Skip to content

Instantly share code, notes, and snippets.

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