home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / sun / misc / TimerTickThread.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  1.6 KB  |  97 lines

  1. package sun.misc;
  2.  
  3. class TimerTickThread extends Thread {
  4.    static final int MAX_POOL_SIZE = 3;
  5.    static int curPoolSize;
  6.    static TimerTickThread pool = null;
  7.    TimerTickThread next;
  8.    Timer timer;
  9.    long lastSleepUntil;
  10.  
  11.    protected static synchronized TimerTickThread call(Timer var0, long var1) {
  12.       TimerTickThread var3 = pool;
  13.       if (var3 == null) {
  14.          var3 = new TimerTickThread();
  15.          var3.timer = var0;
  16.          var3.lastSleepUntil = var1;
  17.          ((Thread)var3).start();
  18.       } else {
  19.          pool = pool.next;
  20.          var3.timer = var0;
  21.          var3.lastSleepUntil = var1;
  22.          synchronized(var3){}
  23.  
  24.          try {
  25.             var3.notify();
  26.          } catch (Throwable var6) {
  27.             throw var6;
  28.          }
  29.       }
  30.  
  31.       return var3;
  32.    }
  33.  
  34.    private boolean returnToPool() {
  35.       Class var2 = this.getClass();
  36.       synchronized(var2){}
  37.  
  38.       try {
  39.          if (curPoolSize >= 3) {
  40.             boolean var20 = false;
  41.             return var20;
  42.          }
  43.  
  44.          this.next = pool;
  45.          pool = this;
  46.          ++curPoolSize;
  47.          this.timer = null;
  48.       } catch (Throwable var19) {
  49.          throw var19;
  50.       }
  51.  
  52.       while(this.timer == null) {
  53.          synchronized(this){}
  54.  
  55.          try {
  56.             try {
  57.                this.wait();
  58.             } catch (InterruptedException var17) {
  59.             }
  60.          } catch (Throwable var18) {
  61.             throw var18;
  62.          }
  63.       }
  64.  
  65.       Class var1 = this.getClass();
  66.       synchronized(var1){}
  67.  
  68.       try {
  69.          --curPoolSize;
  70.       } catch (Throwable var16) {
  71.          throw var16;
  72.       }
  73.  
  74.       return true;
  75.    }
  76.  
  77.    public void run() {
  78.       do {
  79.          this.timer.owner.tick(this.timer);
  80.          TimerThread var1 = TimerThread.timerThread;
  81.          synchronized(var1) {
  82.             Timer var3 = this.timer;
  83.             synchronized(var3){}
  84.  
  85.             try {
  86.                if (this.lastSleepUntil == this.timer.sleepUntil) {
  87.                   TimerThread.requeue(this.timer);
  88.                }
  89.             } catch (Throwable var6) {
  90.                throw var6;
  91.             }
  92.          }
  93.       } while(this.returnToPool());
  94.  
  95.    }
  96. }
  97.