A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

package java.util

Code Examples of java.util.TimerTask

A task that can be scheduled for one-time or repeated execution by a Timer. @author Josh Bloch @version 1.11, 11/17/05 @see Timer @since 1.3

View Full Code of java.util.TimerTask


        log.info("Waiting for Geronimo server...");

        // Setup a callback to time out verification
        final ObjectHolder verifyTimedOut = new ObjectHolder();

        TimerTask timeoutTask = new TimerTask() {
            public void run() {
                verifyTimedOut.set(Boolean.TRUE);
            }
        };

        if (verifyTimeout > 0) {
            if (log.isDebugEnabled()) {
                log.debug("Starting verify timeout task; triggers in: " + verifyTimeout + " seconds");
            }
            timer.schedule(timeoutTask, verifyTimeout * 1000);
        }

        // Verify server started
        ServerProxy server = new ServerProxy(hostname, port, username, password);
        boolean started = false;
        while (!started) {
            if (verifyTimedOut.isSet()) {
                throw new MojoExecutionException("Unable to verify if the server was started in the given time (" + verifyTimeout + " seconds)");
            }

            if (errorHolder.isSet()) {
                throw new MojoExecutionException("Failed to start Geronimo server", (Throwable)errorHolder.get());
            }

            started = server.isFullyStarted();

            if (!started) {
                Throwable error = server.getLastError();
                if ((error != null) && (log.isDebugEnabled())) {
                    log.debug("Server query failed; ignoring", error);
                }

                Thread.sleep(1000);
            }
        }
        server.closeConnection();

        // Stop the timer, server should be up now
        timeoutTask.cancel();

        log.info("Geronimo server started in " + watch);

        if (!background) {
            log.info("Waiting for Geronimo server to shutdown...");

View Full Code Here


        log.info("Waiting for Geronimo server...");

        // Setup a callback to time out verification
        final ObjectHolder verifyTimedOut = new ObjectHolder();

        TimerTask timeoutTask = new TimerTask() {
            public void run() {
                verifyTimedOut.set(Boolean.TRUE);
            }
        };

        if (timeout > 0) {
            log.debug("Starting verify timeout task; triggers in: " + timeout + "s");
            timer.schedule(timeoutTask, timeout * 1000);
        }

        // Verify server started
        ServerProxy server = new ServerProxy(hostname, port, username, password);
        boolean started = false;
        while (!started) {
            if (verifyTimedOut.isSet()) {
                throw new MojoExecutionException("Unable to verify if the server was started in the given time");
            }

            started = server.isFullyStarted();

            if (!started) {
                Throwable error = server.getLastError();
                if (error != null) {
                    log.debug("Server query failed; ignoring", error);
                }

                Thread.sleep(1000);
            }
        }
        server.closeConnection();

        // Stop the timer, server should be up now
        timeoutTask.cancel();

        log.info("Geronimo server started");
    }

    protected String getFullClassName() {

View Full Code Here



	@Override
	public void init(Queue<Packet> results) {
		super.init(results);
		tasks = new Timer("SystemMonitorTask", true);
		tasks.scheduleAtFixedRate(new TimerTask() {
			public void run() {
				monitor10Secs();
			}
		}, INTERVAL_10SECS, INTERVAL_10SECS);
		tasks.scheduleAtFixedRate(new TimerTask() {
			public void run() {
				monitor1Min();
			}
		}, INTERVAL_1MIN, INTERVAL_1MIN);
		tasks.scheduleAtFixedRate(new TimerTask() {
			public void run() {
				monitor1Hour();
			}
		}, INTERVAL_1HOUR, INTERVAL_1HOUR);
		tasks.scheduleAtFixedRate(new TimerTask() {
			public void run() {
				monitor1Day();
			}
		}, INTERVAL_1DAY, INTERVAL_1DAY);
	}

View Full Code Here


		} catch (JMuleManagerException e) {
			e.printStackTrace();
			return ;
		}
		remove_temp_banned_peers_timer = new Timer( "Remove temp banned peers timer", true );
		remove_temp_banned_peers_timer.scheduleAtFixedRate(new TimerTask() {
			@Override
			public void run() {
				for(TemporaryBannedIP banned_ip : temporary_banned_peers) 
					if( ( System.currentTimeMillis() - banned_ip.getWhenBanned() ) >= banned_ip.getHowLong() )
						temporary_banned_peers.remove( banned_ip );
			}
		}, (long)1, REMOVE_TEMP_BANNED_PEERS_INTERVAL);
		
		remove_temp_banned_servers_timer = new Timer( "Remove temp banned servers timer", true);
		remove_temp_banned_servers_timer.scheduleAtFixedRate(new TimerTask() {
			@Override
			public void run() {
				for(TemporaryBannedIP banned_ip : temporary_banned_servers) 
					if( ( System.currentTimeMillis() - banned_ip.getWhenBanned() ) >= banned_ip.getHowLong() )
						temporary_banned_servers.remove( banned_ip );

View Full Code Here



    public void start() {
        MUCEventDispatcher.addListener(this);

        // Schedule a task for this new transcript event queue.
        transcriptUpdateTask = new TimerTask() {
            @Override
			public void run() {
                if (roomEvents.isEmpty()) {
                    return;
                }

View Full Code Here


    /**
     * Hide the constructor so no one can create other instances
     */
    private QueuedTasksManager() {
        // Register a periodic task that will execute queued tasks
        TaskEngine.getInstance().scheduleAtFixedRate(new TimerTask() {
            @Override
			public void run() {
                if (!ClusterManager.isClusteringStarting()) {
                    MUCRoomTask mucRoomTask;
                    while ((mucRoomTask = taskQueue.poll()) != null) {

View Full Code Here


        this.executor = executor;
    }

    @Override
    public void handleHttpRequest(final HttpRequest request, final HttpResponse response, final HttpControl control) throws Exception {
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                executor.execute(new Runnable() {
                    @Override
                    public void run() {

View Full Code Here


		try {
			st.add(ti);
		} catch (AWTException e) {

		}
		new Timer("Splash closer", true).schedule(new TimerTask() {
			@Override
			public void run() {
				SplashScreen ss = SplashScreen.getSplashScreen();
				if (ss != null)
					ss.close();

View Full Code Here


            threads[i].start();
         }

         alignLatch.await();

         timer.schedule(new TimerTask()
         {
            @Override
            public void run()
            {
               try

View Full Code Here


  private Timer timer;

  public void contextInitialized(ServletContextEvent servletContextEvent) {
    log.info("Starting newsfeed updater");
    timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
      public void run() {
        try {
          NewsFeedCache.getInstance().refreshFeeds();
        } catch (Exception e) {
          log.error("Error while refreshing feeds " + e.getMessage());

View Full Code Here


		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				final long started = lastInsert = System.currentTimeMillis();
				if (!getSelectionWindow().isVisible()) {
					if (isAnyValueStartingWith(getLastWord())) {
						new Timer(true).schedule(new TimerTask() {
							public void run() {
								if (lastInsert == started
										&& !getSelectionWindow().isVisible()) {
									model.fireChange();
									showWindow();

View Full Code Here


        this.deadlockCheckPeriod = deadlockCheckPeriod;
    }

    public void start() {
        if(started.compareAndSet(false, true)) {
            threadCheck.schedule(new TimerTask() {
                public void run() {
                    checkForDeadlocks();
                }
            }, 10, deadlockCheckPeriod);
        }

View Full Code Here


                final HostObjectServiceListener listener = new HostObjectServiceListener(componentContext.getBundleContext(), hostObjectsThatNeedServices);
                bundleContext.addServiceListener(listener);
                listener.start();
                if (!hostObjectsThatNeedServices.isEmpty()) {
                    Timer timer = new Timer();
                    timer.scheduleAtFixedRate(new TimerTask() {
                        public void run() {
                            try {
                                if (!hostObjectsThatNeedServices.isEmpty()) {
                                    log.warn("JS Deployer initialization is delayed due to the following unsatisfied Host Objects..");
                                    for (String configItem : hostObjectsThatNeedServices) {

View Full Code Here


                    IConnection connection = PacketTool.this.conn;
                    if (connection != null)
                        connection.update();
                }
            };
            final TimerTask packetUpdate2 = new TimerTask() {
                public void run() {
                    try {
                        SwingUtilities.invokeAndWait(packetUpdate);
                    } catch (Exception ie) {
                    }

View Full Code Here


     * let those exceptions bubble up, where they will both notify the thread's
     * uncaught exception handler and terminate the timer's thread.
     */
    public void testThrowingTaskKillsTimerThread() throws InterruptedException {
        final AtomicReference<Thread> threadRef = new AtomicReference<Thread>();
        new Timer().schedule(new TimerTask() {
            @Override public void run() {
                threadRef.set(Thread.currentThread());
                throw new RuntimeException("task failure!");
            }
        }, 1);

View Full Code Here

TOP

View Full Code of java.util.TimerTask

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

TOP