Skip to content

Instantly share code, notes, and snippets.

@maruks
Created February 24, 2012 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maruks/1902213 to your computer and use it in GitHub Desktop.
Save maruks/1902213 to your computer and use it in GitHub Desktop.
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