SHARE
TWEET

Java Puzzle 2: Dreams (solution)

a guest Feb 24th, 2012 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package dream;
  2.  
  3. import sleep.Sleeper;
  4.  
  5. public class Dream {
  6.  
  7.         public void dream(final Sleeper s) {
  8.                 Thread thread = new Thread(new Runnable() {
  9.                         public void run() {
  10.                                 s.enter(new Dream() {
  11.                                         @Override
  12.                                         public void dream(Sleeper s) {
  13.                                                 try {
  14.                                                         s.wait(500);
  15.                                                 } catch (InterruptedException e) {
  16.                                                 }
  17.                                         }
  18.                                 });
  19.                         }
  20.                 });
  21.                 thread.start();
  22.                 try {
  23.                         s.wait(100);
  24.                 } catch (InterruptedException e) {
  25.                 }
  26.         }
  27.  
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top