Example usage for java.util Timer schedule

List of usage examples for java.util Timer schedule

Introduction

In this page you can find the example usage for java.util Timer schedule.

Prototype

public void schedule(TimerTask task, Date firstTime, long period) 

Source Link

Document

Schedules the specified task for repeated fixed-delay execution, beginning at the specified time.

Usage

From source file:BufferedAnimate.java

public void go() {
    TimerTask task = new TimerTask() {
        public void run() {
            Color c = colors[0];//  www  .ja v  a 2 s  . c om
            synchronized (colors) {
                System.arraycopy(colors, 1, colors, 0, colors.length - 1);
                colors[colors.length - 1] = c;
            }
            repaint();
        }
    };
    Timer timer = new Timer();
    timer.schedule(task, 0, DELAY);
}

From source file:emperior.Main.java

public static void removeTabbedPaneIcon() {
    final Timer timer = new Timer();
    TimerTask task = new TimerTask() {
        @Override/*from w  w  w  .j a v  a  2  s . c  o  m*/
        public void run() {
            int index = MainFrame.jTabbedPane.getSelectedIndex();
            if (MainFrame.jTabbedPane.getIconAt(index) != null) {
                MainFrame.jTabbedPane.setIconAt(index, null);
                timer.cancel();
            }
        }
    };
    timer.schedule(task, 100, 60000);

}

From source file:me.ryandowling.NowPlayingConverter.java

public void run() {
    TimerTask task = new FileWatcher(Utils.getNowPlayingRawPath().toFile()) {
        @Override/*from ww  w  . j  a  va2  s  .c  o  m*/
        protected void onChange(File file) {
            updateFiles();
        }
    };

    Timer timer = new Timer();
    timer.schedule(task, new Date(), this.delay);
}

From source file:nl.ordina.bag.etl.mail.scheduler.JobScheduler.java

public void init() {
    if (enabled) {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override/*from ww w .j  av  a2s . c om*/
            public void run() {
                execute();
            }
        }, delay, period);
    }
}

From source file:co.mafiagame.engine.util.PurgeTimer.java

@PostConstruct
public void initPurgeTimer() {
    Calendar now = Calendar.getInstance();
    now.add(Calendar.SECOND, 10);
    now.add(Calendar.DATE, 1);/* w  w  w  .  java2 s  .  c  o  m*/
    now.set(Calendar.HOUR_OF_DAY, 6);
    Timer timer = new Timer();
    timer.schedule(this, now.getTime(), 24 * 60 * 60 * 1000);
}

From source file:com.ifpe.poker.model.NewEmptyJUnitTest.java

@Test
public void hello() {
    Timer timer = new Timer();
    timer.schedule(new TimerTask() {
        int i = 10;

        @Override// ww w  . j a  v a  2  s  .  com
        public void run() {
            if (i <= 0) {
                cancel();
            }
            System.out.println(i--);
        }
    }, 5000, 1000);

    //        assertSame(player, list.get(0));
}

From source file:srvclientmonitor.thGetStatusServices.java

@Override
public void run() {

    Timer t1 = new Timer();
    t1.schedule(new myTimerTask(), 5000, 5000);
}

From source file:org.apache.ivory.service.LogCleanupService.java

@Override
public void init() throws IvoryException {
    Timer timer = new Timer();
    timer.schedule(new CleanupThread(), 0, getDelay());
    LOG.info("Ivory log cleanup service initialized");

}

From source file:org.apache.falcon.service.LogCleanupService.java

@Override
public void init() throws FalconException {
    Timer timer = new Timer();
    timer.schedule(new CleanupThread(), 0, getDelay());
    LOG.info("Falcon log cleanup service initialized");
}

From source file:srvmonitor.thKeepAliveServices.java

@Override
public void run() {
    Thread tr = Thread.currentThread();
    System.out.println("Current Thread KeepAlive: " + tr.getName() + " ID: " + tr.getId());

    Timer timerMain = new Timer("thSubKeep");
    timerMain.schedule(new mainKeepTask(), 1000, 10000);
}