home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / main / nowblinkthread.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  791 b   |  47 lines

  1. // NowBlinkThread.java
  2. // 26.03.96
  3. //
  4. // makes the lights on the NowPanel blink
  5.  
  6. package cybcerone.main;
  7.  
  8. /**
  9.  * The thread that the NowPanel spawns to make its lights blink.
  10.  */
  11. class NowBlinkThread extends Thread {
  12.   private final int onTime = 350;
  13.   private final int offTime = 1050;
  14.  
  15.   private NowPanel theNow;
  16.  
  17.   public NowBlinkThread (NowPanel theNow) {
  18.     this.theNow = theNow;
  19.   }
  20.  
  21.   public void run () {
  22.     int i;
  23.     NowEventPanel panels[] = theNow.getPanels ();
  24.  
  25.     while (true) {
  26.  
  27.       try {
  28.     sleep (offTime);
  29.       } catch (InterruptedException e) {
  30.       }
  31.  
  32.       for (i = 0; i < theNow.getActivePanels(); i++) {
  33.     panels[i].turnLightsOn ();
  34.     
  35.     try {
  36.       sleep (onTime);
  37.     } catch (InterruptedException e) {
  38.     }
  39.     
  40.     panels[i].turnLightsOff ();
  41.       }
  42.       
  43.     }
  44.   }
  45. }
  46.       
  47.