⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scheduler.java

📁 java与模式 一书的源码
💻 JAVA
字号:
package com.javapatterns.chainofresp.scheduler;

import java.util.*;
import java.io.IOException;
  
public class Scheduler
{
   private static Timer timer = new Timer();

   public static void main(String []args)
   {
      Calendar calendar = Calendar.getInstance();
      calendar.set(Calendar.HOUR_OF_DAY, 10);
      calendar.set(Calendar.MINUTE, 30);
      calendar.set(Calendar.SECOND, 30);
      Date time = calendar.getTime();
 
      timer.schedule(new ScheduledTask(), time);
      System.out.println("A job has been scheduled at " + time);
   }
 
   static class ScheduledTask extends TimerTask
   {
      public void run()
      {
		try
        {
	        String command = "notepad c:/boot.ini";
	        Process child = Runtime.getRuntime().exec(command);
            System.out.println("The scheduled job has been executed.");
		}
        catch (IOException e)
        {
            System.out.println("Exception " + e);
		}
      }
   }
} 


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -