Package java.util

Examples of java.util.Timer.scheduleAtFixedRate()


        marketDatas.add(new MarketData("EurNY", 0, 0));
        marketDatas.add(new MarketData("EurNY1", 0, 0));
        marketDatas.add(new MarketData("EurNY2", 0, 0));

        final Timer timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {

            @Override
            public void run() {
                final MarketData market = marketDatas.get(rdm.nextInt(marketDatas.size()));
                final MarketData price = new MarketData(market.getCurrency(), (int) (Math.random() * 99), (int) (Math.random() * 99));
 
View Full Code Here


            final Timer timer = new Timer();

            @Override
            public void onOpen() {

                timer.scheduleAtFixedRate(new TimerTask() {

                    @Override
                    public void run() {
                        pusher.execute(new Runnable() {
View Full Code Here

    private RequestResponseApi request;

    public void init() {
        Timer timer = new Timer();
        //Start the task with a fixed delay of 5000 ms after 500 ms.
        timer.scheduleAtFixedRate(new ConsoleResponder(request), 500l, 5000l);

    }

    public void setRequest(RequestResponseApi request) {
        this.request = request;
View Full Code Here

  @Override
  public void run() {
    vehicle = new DefaultVehicle(WIDTH / 2, HEIGHT / 2, queue, obstacles);

    Timer timer = new Timer("Vehicle Timer", true);
    timer.scheduleAtFixedRate(vehicle, 0, Vehicle.DELAY_TIME);
  }

  /*
   * (non-Javadoc)
   * @see org.lekan.graphics.GraphicsProgram#keyPressed(java.awt.event.KeyEvent)
View Full Code Here

    Cancellable contextCancellable = getContext().announce(serviceName, port);
    LOG.info("Announced HTTP Service");

    // Create a Timer thread to periodically collect handler that are no longer in used and call destroy on it
    Timer timer = new Timer("http-handler-gc", true);
    timer.scheduleAtFixedRate(createHandlerDestroyTask(), HANDLER_CLEANUP_PERIOD_MS, HANDLER_CLEANUP_PERIOD_MS);

    try {
      completion.get();
    } catch (InterruptedException e) {
      LOG.error("Caught exception in HTTP Service run", e);
View Full Code Here

        if(perfmonIntervalnMills == -1 || !LOG.isInfoEnabled()) {
            return;
        }
        PerfmonTask task = new PerfmonTask();
        Timer timer = new Timer(SRV_NAME, true);
        timer.scheduleAtFixedRate(task, 1000, perfmonIntervalnMills);
        this._status = Status.started;
    }

    public void stop() throws ServiceException {
        if(timer != null) {
View Full Code Here

            resourceConfig.registerInstances(new ContainerLifecycleListener() {
                @Override
                public void onStartup(Container container) {
                    App.container = container;
                    Timer t = new Timer(true);
                    t.scheduleAtFixedRate(new FileCheckTask(0), 0, REFRESH_PERIOD_MS);
                }

                @Override
                public void onReload(Container container) {
                    System.out.println("Application has been reloaded!");
View Full Code Here

        setResizable(false);
        setSize(300,125);
        show();
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Timer displayTimer = new Timer();
        displayTimer.scheduleAtFixedRate(new TimerTask() {
            public void run() {
                display.setText(DISPLAY_PREFIX + stopWatch.getDisplay()
                    + DISPLAY_SUFFIX);
                state.setText(STATE_PREFIX + stopWatch.getCurrentState()
                    + STATE_SUFFIX);
View Full Code Here

                listenerThread.start();

                Broadcaster broadcaster = new Broadcaster();

                Timer timer = new Timer("MulticastDiscovery: Broadcaster", true);
                timer.scheduleAtFixedRate(broadcaster, 0, heartRate);
            }
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }
View Full Code Here

        System.out.println("-------------------------------");

        if (send != null) {
            Timer timer = new Timer("Multicast Send", true);
            timer.scheduleAtFixedRate(new Send(address, multicast, send), 0, rate);
        }

        byte[] buf = new byte[BUFF_SIZE];
        DatagramPacket packet = new DatagramPacket(buf, 0, buf.length);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.