Created
February 24, 2012 17:25
-
-
Save maruks/1902213 to your computer and use it in GitHub Desktop.
solution of 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
package dream; | |
import sleep.Sleeper; | |
public class Dream { | |
int num = 0; | |
public void dream(final Sleeper s) { | |
if (num++ < 10) { | |
Thread thread = new Thread(new Runnable() { | |
public void run() { | |
s.enter(Dream.this); | |
} | |
}); | |
thread.start(); | |
synchronized (s) { | |
try { | |
s.wait(100); | |
} catch (InterruptedException e) { } | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment