Example usage for java.util Timer Timer

List of usage examples for java.util Timer Timer

Introduction

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

Prototype

public Timer() 

Source Link

Document

Creates a new timer.

Usage

From source file:J2MEFixedRateSchedule.java

public void startApp() {
    d.addCommand(new Command("Exit", Command.EXIT, 0));
    d.setCommandListener(new CommandListener() {
        public void commandAction(Command c, Displayable s) {
            notifyDestroyed();/*from ww w  .j a v  a2  s  .c om*/
        }
    });
    now.setTime(currentTime);

    nowString = now.get(Calendar.HOUR) + ":" + now.get(Calendar.MINUTE) + ":" + now.get(Calendar.SECOND) + ":";

    aTimer = new Timer();
    aTimerTask = new ClockTimerTask();
    aTimer.scheduleAtFixedRate(aTimerTask, 10, 1000);

    Display.getDisplay(this).setCurrent(d);
}

From source file:Main.java

public ExecuteTask(Runnable task) {
    this.owner = new Timer();
    this.task = task;
    upTo.put(owner, currentTimeMillis() + random.nextInt(10) * 1000);
}

From source file:SimpleTimerMIDlet.java

public void commandAction(Command c, Displayable s) {
    if (c == scheduleCommand) {
        aTimer = new Timer();
        aTimerTask = new SimpleTimerTask();
        aTimer.schedule(aTimerTask, 500);
        aTextBox.setString(aMessage);/*from   w w  w.java2s  .  c o m*/
    } else if (c == exitCommand) {
        destroyApp(false);
        notifyDestroyed();
    }
}

From source file:SimpleTimerCancelMIDlet.java

public void commandAction(Command c, Displayable s) {
    if (c == scheduleCommand) {
        aTimer = new Timer();
        aTimerTask = new SimpleTimerTask();
        aTimer.schedule(aTimerTask, 500);
        aTextBox.setString(aMessage);//  w  ww .  j  a  v a2  s . com
    } else if (c == exitCommand) {
        destroyApp(false);
        notifyDestroyed();
    }

}

From source file:com.pureinfo.srm.sender.engines.SRMMailEngine.java

protected void doStartup() throws PureException {
    if (logger.isInfoEnabled()) {
        logger.info("mail engine startup.");
    }//from  w  w  w  .j  av  a2  s . c om

    m_timer = new Timer();
    m_timer.schedule(new TimerTask() {
        public void run() {
            try {
                SRMMailMachine machine = new SRMMailMachine();
                machine.send();
            } catch (Exception e) {
                logger.warn("mail engine error,", e);
            }
        }
    }, DELAY, PERIOD);
}

From source file:net.rptools.maptool.client.ChatAutoSave.java

private ChatAutoSave() {
    log.debug("Creating chat log autosave timer"); //$NON-NLS-1$
    // Only way to set the delay is to call changeTimeout()
    delay = 0;// w  w  w .  j ava2  s  .  c o  m
    countdown = new Timer();
}

From source file:me.ryandowling.NowPlayingConverter.java

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

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

From source file:com.pureinfo.srm.sendoutlayunit.engines.SRMOutlayUnitEngine.java

protected void doStartup() throws PureException {
    // TODO Auto-generated method stub
    if (logger.isInfoEnabled()) {
        logger.info("outlayunit engine startup.");
    }//www.j  a  v  a2s .  c o m

    m_timer = new Timer();
    m_timer.schedule(new TimerTask() {
        public void run() {
            try {

            } catch (Exception e) {
                logger.warn("outlayunit engine error,", e);
            }
        }
    }, DELAY, PERIOD);

}

From source file:com.voa.weixin.mission.MissionManager.java

private MissionManager() {
    timer = new Timer();
    missions = new HashMap<String, Mission>();

    init();
}