package com.uvigo.mhp.ui;

import org.havi.ui.*;

class HActionedThread extends Thread
{
    private HGraphicButton b;
    private int millis;
    private boolean flag;
    
    HActionedThread(HGraphicButton b, int millis)
    {
        this.b=b;
        this.millis=millis;
        flag=true;
    }
    
    public synchronized void run()
    {
        while(flag)
        {
            try
            {
                if (b instanceof HButton)
                    ((HButton) b).fireEvent();
                if (b instanceof HSwitch)
                   ((HSwitch) b).fireEvent();
                wait(millis);
            }
            catch (Exception e)
            {}
        }
    }
    
    public synchronized void off()
    {
        flag=false;
        interrupt();
    }
}