java.util.TimerTask.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中java.util.TimerTask.<init>()方法的一些代码示例,展示了TimerTask.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimerTask.<init>()方法的具体详情如下:
包路径:java.util.TimerTask
类名称:TimerTask
方法名:<init>

TimerTask.<init>介绍

[英]Creates a new TimerTask.
[中]

代码示例

代码示例来源:origin: stackoverflow.com

final int FPS = 40;
TimerTask updateBall = new UpdateBallTask();
timer.scheduleAtFixedRate(updateBall, 0, 1000/FPS);

代码示例来源:origin: stackoverflow.com

foo() {
 synchronized(lock) {
   someMethod(new TimerTask() {
    public void run() {
      synchronized(lock)  {
          //stuff
      }
    }
  }

代码示例来源:origin: stackoverflow.com

TimerTask timerTask = new MyTimerTask();
// They're ms: 1000ms = 1s
timer.scheduleAtFixedRate(timerTask, 0, 1000);
timer.start();

代码示例来源:origin: stackoverflow.com

if(condition == true)
{ 
timer = new Timer();
  timer.schedule(new TimerTask(), delay, span);
}
else{
  timer.cancel();
}

代码示例来源:origin: stackoverflow.com

t.cancel();
t = new Timer();
TimerTask newTask = new MyTimerTask();  // new instance
t.schedule(newTask, timeDelay);

代码示例来源:origin: stackoverflow.com

public class ChangeProfileActivityMain extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    Timer timer = new Timer();
    TimerTask updateProfile = new CustomTimerTask(ChangeProfileActivityMain.this);
    timer.scheduleAtFixedRate(updateProfile, 0, 5000);
  }

}

代码示例来源:origin: stackoverflow.com

if (result == 2) {
  TimerTask tasknew = new TimerScheduleFixedRateDelay();
  Timer timer = new Timer();
  // scheduling the task at fixed rate delay
  timer.scheduleAtFixedRate(tasknew, 1000, 1000);
  @Override
}

public void run() {

代码示例来源:origin: stackoverflow.com

// creating timer task, timer
  TimerTask tasknew = new TimerScheduleDelay();
  Timer timer = new Timer();
  // scheduling the task at interval
  timer.schedule(tasknew, 100);      
 }
 // this method performs the task
 public void run() {
  System.out.println("timer working");      
 }

代码示例来源:origin: stackoverflow.com

@Override
protected void onCreate(Bundle bundle)
{
  ...
  Timer timer = new Timer();
  TimerTask updateColor = new SwitchColorTask();
  timer.scheduleAtFixedRate(updateColor, 100, 100);
  ...
}

代码示例来源:origin: stackoverflow.com

public void timer() {

  TimerTask tasknew = new MyTask();
  Timer timer = new Timer();

  /* scheduling the task, the first argument is the task you will be 
   performing, the second is the delay, and the last is the period. */
  timer.schedule(tasknew, 100, 100);
}

代码示例来源:origin: stackoverflow.com

int timer_wait_time= 5000;  // in miliseconds
Timer timer = new Timer();
TimerTask myTT= new MyTimerTask();
timer.schedule(myTT, timer_wait_time);

代码示例来源:origin: stackoverflow.com

TimerTask tasknew = new TimerSchedulePeriod();
Timer timer = new Timer();
// scheduling the task at interval
timer.schedule(tasknew,100, 100);

代码示例来源:origin: stackoverflow.com

scheduler(){
TimerTask tasknew = new TimerSchedulePeriod();
Timer timer = new Timer();
// scheduling the task at interval
timer.schedule(tasknew,100, 100); 
}
// this method performs the task
public void run() {
System.out.println("timer working");      
}

代码示例来源:origin: stackoverflow.com

import java.util.*;
public class TimerDemo {
  public static void main(String[] args) {

   TimerTask tasknew = new TimerScheduleFixedRateDelay();
   Timer timer = new Timer();

   timer.scheduleAtFixedRate(tasknew, 500, 1000);      
  }

  public void run() {
   System.out.println("working at fixed rate delay");      
  }    
}

代码示例来源:origin: stackoverflow.com

try {
  Timer timer = new Timer(true);
  TimerTask interruptTimerTask = new InterruptTimerTask(Thread.currentThread());
  timer.schedule(interruptTimerTask, howLongDoYouWantToWait);
  rMIinstance.ping();
  timer.cancel();
} catch (RemoteException | InterruptedException e) {
  getInstanceRegister().removeInstance(rMIinstance);
}

代码示例来源:origin: stackoverflow.com

public class TimerDemo {
   public static void main(String[] args) {
     // creating timer task, timer
     TimerTask tasknew = new TimerSchedulePeriod();
     Timer timer = new Timer();

     // scheduling the task at interval
     timer.schedule(tasknew, 0, 10);      
   }

  // this method performs the task
  public void run() {
     System.out.println("timer working");      
  }    
}

代码示例来源:origin: stackoverflow.com

// single shared timer instance
Timer t = new Timer();

// for each device
Process p = pb.start();
TimerTask killer = new TimeoutProcessKiller(p);
t.schedule(killer, 30000);
// ... read output stream as before ...
int returnVal = p.waitFor();
killer.cancel();

代码示例来源:origin: stackoverflow.com

listUpdater = new Thread() {
  @Override
  public void run() {
    TimerTask task = new UpdateListTask();

    while (updateList) {
      task.run();
    }
  }
};
updateList = true;
listUpdater.start();

代码示例来源:origin: stackoverflow.com

mStartButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mTimerTask = new TimerTask();//This creates new TimerTask 
timer = new Timer(); //Instantiate again, as we Cancel the Timer
timer.schedule(mTimerTask, 0, 30);
}
});

mEndButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
timer.cancel();
timer.purge();
}
});

代码示例来源:origin: igniterealtime/Spark

@Override
  public void run() {
    PrivacyManager.getInstance(); // Initiating PrivacyLists
    TimerTask thread = new TimerTask() {
      @Override
      public void run() {
        addMenuItemToContactItems();
      }
    };
    TaskEngine.getInstance().schedule(thread, 500);
  }
};

相关文章