FileDocCategorySizeDatePackage
Timer.javaAPI DocJMF 2.1.1e1787Mon May 12 12:20:56 BST 2003com.sun.media.rtsp

Timer

public class Timer extends Thread implements Runnable

Fields Summary
private Vector
listeners
private long
duration
private boolean
stopped
Constructors Summary
public Timer(TimerListener listener, long duration)

        listeners = new Vector();

        this.duration = duration / 1000000;

        addListener(listener);

        stopped = false;
    
Methods Summary
public voidaddListener(com.sun.media.rtsp.TimerListener listener)

        listeners.addElement(listener);
    
public voidremoveListener(com.sun.media.rtsp.TimerListener listener)

        listeners.removeElement(listener);
    
public voidreset()

    
public voidrun()

        // System.out.println( "start timer for " + duration + "ms");

        synchronized (this) {
            try {
                wait(duration);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        if (!stopped) {
            for (int i = 0; i < listeners.size(); i++) {
                TimerListener listener = (TimerListener) listeners.elementAt(i);

                listener.timerExpired();
            }
        }
    
public voidstopTimer()

        // System.out.println( "stop timer");

        stopped = true;

        synchronized (this) {
            notify();
        }