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:Main.java

public Main() {
    toolkit = Toolkit.getDefaultToolkit();
    timer = new Timer();
    timer.scheduleAtFixedRate(new RemindTask(), 0, //initial delay
            1 * 1000); //subsequent rate
}

From source file:net.jetrix.filter.SuddenDeathFilter.java

public void onMessage(StartGameMessage m, List<Message> out) {
    out.add(m);// w ww  .j a va 2 s  . co m

    if (getChannel().getGameState() == STOPPED) {
        stopWatch.reset();
        stopWatch.start();
    }

    Settings settings = getChannel().getConfig().getSettings();
    int time = settings.getSuddenDeathTime() * 1000;

    if (time > 0) {
        // start the monitoring thread
        timer = new Timer();
        timer.schedule(new Task(time), max(0, time - Task.WARNING_DELAY * 1000), 200);
    }
}

From source file:AnnoyingBeep.java

public AnnoyingBeep() {
    toolkit = Toolkit.getDefaultToolkit();
    timer = new Timer();
    timer.schedule(new RemindTask(), 0, //initial delay
            1 * 1000); //subsequent rate
}

From source file:SkippingBeep.java

public SkippingBeep() {
    toolkit = Toolkit.getDefaultToolkit();
    timer = new Timer();
    timer.scheduleAtFixedRate(new RemindTask(), 0, //initial delay
            1 * 1000); //subsequent rate
}

From source file:org.sample.TimeController.java

@RequestMapping(method = RequestMethod.GET, value = { "/tick" })
public ModelAndView get() throws Exception {
    Connection connection = jmsFactory.createConnection();
    Session jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    SecureRandom srandom = new SecureRandom();
    String rand = new BigInteger(176, srandom).toString(32);
    String q = Long.toString(System.currentTimeMillis()) + "-" + rand;
    Destination destination = jmsSession.createQueue(q);

    Timer timer = new Timer();
    long delay = 1 * 1000;
    timer.schedule(new TickTask(jmsSession, destination), 0, delay);

    ModelAndView mav = new ModelAndView("client");
    mav.addObject("queue", destination.toString());
    return mav;/*from  w  ww  .j  a  v a2  s.  c  o m*/
}

From source file:RLCcircuit.RLCcircuitJFrame.java

public void VoltageInput(boolean StartOrStop) {
    if (!StartOrStop) {
        if (task != null) {
            task.cancel();/*w  ww.j a  v a 2  s  .  c  o  m*/
            task = null;
        }

        return;
    }

    if (timer == null)
        timer = new Timer();

    //        time = 0;
    task = new TimerTask() {
        public void run() {
            graphPanel.repaint();
            time = time + 1;
        }
    };
    timer.scheduleAtFixedRate(task, 0, 100);
}

From source file:samples.piggate.com.piggateCompleteExample.Service_Notify.java

@Override
public void onCreate() {
    super.onCreate();

    _piggate = new Piggate(this);

    timer = new Timer();
    timer.schedule(new TimerTask() {
        @Override/*from   w w  w  .j  ava2  s.  c  o m*/
        public void run() {
            updateNotificationMsg(); //refresh the notification message
        }
    }, 0, 10000); //Time between calls

    _piggate.setListenerBeacon(new Piggate.PiggateBeaconCallback() { //Set the beacon listener

        //Handle if the device is not compatible
        @Override
        public void DeviceNotCompatible() {
            //Unused
        }

        //Handle if the bluetooth is not connected
        @Override
        public void BluetoothNotConnect() {
            //Unused
        }

        //Handle the pre - scanning of the beacons
        @Override
        public void PreScanning() {
            //Unused
        }

        //Handle the actions when the listener is ready
        @Override
        public void onReady() {
            //Unused
        }

        //Handle the beacon scanning errors
        @Override
        public void onErrorScanning() {
            //Unused
        }

        //Handle the actions where new beacons are discovered
        @Override
        public void GetNewBeacons(ArrayList<PiggateBeacon> beacons) {
            //Do a post notification to the notification bar when a beacon (an offer) is near with a custom message
            _piggate.postNotification(notificationtitle, notificationMsg, Activity_Main.class, R.drawable.logo);
            NotifyNewBeacons(); //Notify the activity about nearby beacons
        }

        //Handles the actions where beacons are detected
        @Override
        public void GetBeacons(ArrayList<PiggateBeacon> beacons) {
            //Unused
        }
    });
    _piggate.onStart(); //handles the onStart method of the Piggae object
}

From source file:samples.piggate.com.piggateInfoDemo.Service_Notify.java

@Override
public void onCreate() {
    super.onCreate();

    _piggate = new Piggate(this);

    timer = new Timer();
    timer.schedule(new TimerTask() {
        @Override/*  w  w w .  j a  v  a  2  s.c  o  m*/
        public void run() {
            updateNotificationMsg(); //refresh the notification message
        }
    }, 0, 10000); //Time between calls

    _piggate.setListenerBeacon(new Piggate.PiggateBeaconCallback() { //Set the beacon listener

        //Handle if the device is not compatible
        @Override
        public void DeviceNotCompatible() {
            //Unused
        }

        //Handle if the bluetooth is not connected
        @Override
        public void BluetoothNotConnect() {
            //Unused
        }

        //Handle the pre - scanning of the beacons
        @Override
        public void PreScanning() {
            //Unused
        }

        //Handle the actions when the listener is ready
        @Override
        public void onReady() {
            //Unused
        }

        //Handle the beacon scanning errors
        @Override
        public void onErrorScanning() {
            //Unused
        }

        //Handle the actions where new beacons are discovered
        @Override
        public void GetNewBeacons(ArrayList<PiggateBeacon> beacons) {
            //Do a post notification to the notification bar when a beacon (an offer) is near with a custom message
            _piggate.postNotification(notificationtitle, notificationMsg, Activity_Main.class, R.drawable.logo);
            NotifyNewBeacons(); //Notify the activity about nearby beaconsd
        }

        //Handles the actions where beacons are detected
        @Override
        public void GetBeacons(ArrayList<PiggateBeacon> beacons) {
            //Unused
        }
    });
    _piggate.onStart(); //handles the onStart method of the Piggae object
}

From source file:ReminderBeep.java

public ReminderBeep(int seconds) {
    toolkit = Toolkit.getDefaultToolkit();
    timer = new Timer();
    timer.schedule(new RemindTask(), seconds * 1000);
}

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.JMTimer.java

/** Creates a new instance of JMTimer */
public JMTimer(DispatchServ dispatcher) {
    this.dispatcher = dispatcher;
    timer = new Timer();
    sessionTasks = new Hashtable();

}