Skip to content

Instantly share code, notes, and snippets.

@aerodame
Last active February 19, 2025 18:53
Show Gist options
  • Save aerodame/50eb5968bbed73802637b16dde91b3b8 to your computer and use it in GitHub Desktop.
Save aerodame/50eb5968bbed73802637b16dde91b3b8 to your computer and use it in GitHub Desktop.
import java.util.concurrent.Semaphore;
public class Deadlock {
public Deadlock( ) {
Semaphore mutex[] = new Semaphore[4];
for ( int i = 0; i < 4; i++ )
mutex[i] = new Semaphore(1);
A threadA = new A( mutex );
B threadB = new B( mutex );
C threadC = new C( mutex );
threadA.start( );
threadB.start( );
threadC.start( );
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment