Java 8 Timer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Timer class.

This code example shows how to use the following methods:cancel
  public void start() { 
    this.timer.scheduleAtFixedRate(new MasterKeyRoller(), 0, rollingInterval);
  } 
 
  public void stop() { 
    this.timer.cancel();
  } 
 
  public synchronized void applicationMasterFinished( 
      ApplicationAttemptId appAttemptId) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Application finished, removing password for " + appAttemptId);
    } 
    this.passwords.remove(appAttemptId);
  } 
 
  private class MasterKeyRoller extends TimerTask {
    @Override 
    public void run() { 
      rollMasterKey(); 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
/** 
 * Timer used for entry expiration in MapMaker. 
 */ 
class ExpirationTimer { 
    static Timer instance = new Timer(true); 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
            	 
				if( (mDragEventStartX > 150) && draggedLotsRight ){ 
            		Log.d(TAG, "Driving animation started Right >"); 
            		takingACorner =true; 
            		slidePic = carRightBitmap; 
            		new Timer().schedule(new TimerTask(){ 
						@Override 
						public void run() { 
							takingACorner =false; 
						}}, 1000); 
            	} 
            	 
            	if( (mDragEventStartX < 150) && draggedLotsLeft ){ 
            		Log.d(TAG, "Driving animation started < Left"); 
            		takingACorner =true;	 
            		slidePic = carLeftBitmap; 
            		new Timer().schedule(new TimerTask(){ 
						@Override 
						public void run() { 
		            		takingACorner =false;
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:cancel
    this.timer.scheduleAtFixedRate(new MasterKeyRoller(), rollingInterval,
        rollingInterval);
  } 
 
  public void stop() { 
    this.timer.cancel();
  } 
 
  /** 
   * Creates a new master-key and sets it as the primary. 
   */ 
  @Private 
  public void rollMasterKey() { 
    super.writeLock.lock(); 
    try { 
      LOG.info("Rolling master-key for container-tokens");
      if (this.currentMasterKey == null) { // Setting up for the first time.
        this.currentMasterKey = createNewMasterKey();
      } else { 
        this.nextMasterKey = createNewMasterKey();
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:schedule
     * @see 
     * android.media.MediaPlayer.OnCompletionListener#onCompletion(android.media 
     * .MediaPlayer) 
     */ 
    public void onCompletion(MediaPlayer mediaplayer) {
        Timer endSound = new Timer();
        endSound.schedule(new TimerTask() {
            public void run() { 
                if (mp != null) {
                    mp.stop();
                    mp.release();
                    mp = null;
                } 
            } 
        }, 200); 
 
    } 
 
    /** 
     * Play sound, either locally (from assets) or remotely via URL. 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:schedule
     * @param startTime 首次运行的时间点 
     * @param period 每次执行任务的间隔时间 
     * @param unit 时间单位 
     */ 
    public static void scheduleAtFixedRate(final Runnable task, Date startTime, final long period, final TimeUnit unit) {
        final Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override 
            public void run() { 
                taskScheduler.scheduleAtFixedRate(task, 0, period, unit);
                timer.cancel();
                timerList.remove(timer);
            } 
        }, startTime);
        timerList.add(timer);
    } 
 
    /** 
     * 立即启动,两次任务间保持固定的时间间隔 
     * @param task 具体待执行的任务 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:schedule
	 
	private void work(){ 
		 
		Location loc = getBestLocation();		
		 
		Timer timer = new Timer(false);
		 
		if(networkEnabled){
			AQUtility.debug("register net"); 
			networkListener = new Listener();
			lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, interval, 0, networkListener, Looper.getMainLooper()); 
			timer.schedule(networkListener, timeout);
		} 
		 
		 
		if(gpsEnabled){
			AQUtility.debug("register gps"); 
			gpsListener = new Listener();
			lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, interval, 0, gpsListener, Looper.getMainLooper());  
			timer.schedule(gpsListener, timeout);

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:cancel
	 * Finalizes the solo object. 
	 */   
 
	@Override 
	public void finalize() throws Throwable { 
		activitySyncTimer.cancel();
		try { 
			// Remove the monitor added during startup 
			if (activityMonitor != null) {
				inst.removeMonitor(activityMonitor);
				activityMonitor = null;
			} 
		} catch (Exception ignored) {}
		super.finalize(); 
	} 
 
	/** 
	 * All activites that have been opened are finished. 
	 */ 
 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
{ 
	private Timer	timer;
 
	public TimeTaskHandler() 
	{ 
		timer = new Timer();
	} 
 
	protected void addTask(TimerTask task, long time)
	{ 
		timer.schedule(task, time);
	} 
 
	protected void addRepetingTask(TimerTask task, long delay, long interval)
	{ 
		timer.scheduleAtFixedRate(task, delay, interval);
	} 
 
	protected void removeTask(TimerTask task)
	{ 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:schedule
        if (ERXProperties.booleanForKey("er.javamail.mailer.ERTestSendingMail")); 
            testSendingMail(); 
        int frequency = ERXProperties.intForKey("er.javamail.mailer.ERBatchMailerDaemonFrequency");
        if (frequency > 0) {
            log.debug("Scheduling timer for frequency: " + frequency + "(s)");
            mailTimer = new Timer(true);
            mailTimer.schedule(new ERMailerTimerTask(), frequency*1000l, frequency*1000l);
        } else { 
            ERMailer.instance().processOutgoingMail(); 
            log.debug("Done processing mail. Exiting.");
            System.exit(0);            
        } 
    } 
 
    public void testSendingMail() { 
        log.info("Sending test mail");
        EOEditingContext ec = ERXEC.newEditingContext();
        ec.lock();
        try { 
            if(false) { 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 Timer Questions & Answers:

See Code Examples for Java 8 Timer Methods: