/[classpath]/classpath/javax/swing/Timer.java
ViewVC logotype

Diff of /classpath/javax/swing/Timer.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by mark, Wed Nov 2 21:30:41 2005 UTC revision 1.23 by mark, Thu Nov 3 00:01:08 2005 UTC
# Line 65  public class Timer Line 65  public class Timer
65       */       */
66      public void run()      public void run()
67      {      {
       running = true;  
68        try        try
69          {          {
70            try            synchronized (queueLock)
             {  
               sleep(initialDelay);  
             }  
           catch (InterruptedException e)  
71              {              {
72                  try
73                    {
74                      queueLock.wait(initialDelay);
75                    }
76                  catch (InterruptedException e)
77                    {
78                      // Ignored
79                    }
80    
81                if (!running)                if (!running)
82                  return;                  return;
             }  
83    
84            queueEvent();                queueEvent();
85    
86            if (repeats)                if (repeats)
87              while (running)                  while (running)
               {  
                 try  
                   {  
                     sleep(delay);  
                   }  
                 catch (InterruptedException e)  
88                    {                    {
89                        try
90                          {
91                            queueLock.wait(delay);
92                          }
93                        catch (InterruptedException e)
94                          {
95                             // Ignored
96                          }
97    
98                      if (!running)                      if (!running)
99                        break;                        break;
                   }  
                 queueEvent();  
100    
101                  if (logTimers)                      queueEvent();
                   System.out.println("javax.swing.Timer -> clocktick");  
102    
103                  if ( ! repeats)                      if (logTimers)
104                    break;                        System.out.println("javax.swing.Timer -> clocktick");
105                }  
106            running = false;                      if (!repeats)
107          }                        break;
108                      }
109                  running = false;
110                }
111            }
112        finally        finally
113          {          {
114            // The timer is no longer running.            // The timer is no longer running.
# Line 408  public class Timer Line 415  public class Timer
415     */     */
416    public void start()    public void start()
417    {    {
418      if (isRunning())      synchronized (queueLock)
419        return;        {
420      waker = new Waker();          if (waker != null)
421      waker.start();            return;
422            waker = new Waker();
423            waker.start();
424          }
425    }    }
426    
427    /**    /**
# Line 419  public class Timer Line 429  public class Timer
429     */     */
430    public void stop()    public void stop()
431    {    {
     running = false;  
     if (waker != null)  
       waker.interrupt();  
432      synchronized (queueLock)      synchronized (queueLock)
433        {        {
434            running = false;
435          queue = 0;          queue = 0;
436            if (waker != null)
437              queueLock.notifyAll();
438            waker = null;
439        }        }
440    }    }
441    

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26