Created
February 23, 2012 16:30
-
-
Save jawher/1893580 to your computer and use it in GitHub Desktop.
Solution to the puzzles dream : http://wouter.coekaerts.be/2012/puzzle-dreams
This file contains 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
class Dream { | |
public void dream(final Sleeper s) { | |
new Thread(new Runnable() { | |
@Override | |
public void run() { | |
s.enter(new Dream() { | |
public void dream(Sleeper s) { | |
synchronized (s) { | |
s.notify(); | |
} | |
synchronized (s) { | |
try { | |
s.wait(); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
}); | |
} | |
}).start(); | |
synchronized (s) { | |
try { | |
s.wait(); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks !
You are indeed right, the program will run indefinitely, but since the puzzle objective was attained, didn't bother with cleaning up afterwards :)