Guest User

Java Puzzle 2: Dreams (solution)

a guest
Feb 24th, 2012
49
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×