Demonstrating One-Shot Execution TimerTask Timer

Listing -. Demonstrating One-Shot Execution
import java.util.Timer;
import java.util.TimerTask;
public class TimerDemo
{
public static void main(String[] args)
{
TimerTask task = new TimerTask()
{
@Override
public void run()
{
System.out.println("alarm going off");
System.exit();
}
};
Timer timer = new Timer();
timer.schedule(task, ); // Execute one-shot timer task after
// 2-second delay.
}
}
上一篇:Javascript的历史


下一篇:json_encode