Last active
August 29, 2015 13:57
-
-
Save DavidYKay/9515851 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
public class Deadlock { | |
static class Friend { | |
private final String name; | |
public Friend(String name) { | |
this.name = name; | |
} | |
public String getName() { | |
return this.name; | |
} | |
public void bow(Friend bower) { | |
System.out.format("%s: %s" | |
+ " has bowed to me!%n", | |
this.name, bower.getName()); | |
} | |
} | |
public static void main(String[] args) { | |
final Friend alphonse = | |
new Friend("Alphonse"); | |
final Friend gaston = | |
new Friend("Gaston"); | |
new Thread(new Runnable() { | |
public void run() { alphonse.bow(gaston); } | |
}).start(); | |
new Thread(new Runnable() { | |
public void run() { gaston.bow(alphonse); } | |
}).start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment