25 abril 2011

#{ TimerTask y schedule }

0 comentarios
import java.util.Timer;
import java.util.TimerTask;

/**
* Clase principal
*/
public class ClaseTimer {   
    private Timer timerCounter;
    private static final int delay = 10;
    private static final int rate = 20;

    public ClaseTimer () {           
        //Iniciacion del Timer
        //Asignacion de la tarea al Timer
        timerCounter = new Timer();
        timerCounter.schedule(new TaskCounter(), delay * 1000, rate * 1000);
    }

    /**
    * Clase interna con la tarea a realizar,
    * Se realiza en la implementacion del metodo run()
    */
    class TaskCounter extends TimerTask {
        public void run() {
            //Tarea(s) a realizar...
            lblAmount2Download.setText(thmail.getMsg2Download());
        }
    }

}

0 comentarios:

Publicar un comentario

 
Buffer de Código | © Design by DheTemplate.com and Theme 2 Blog

Find more free Blogger templates at DheTemplate.com - Daily Updates Free Blogger Templates