to:zhangzxiaogen能否详细点!!

解决方案 »

  1.   

    如果是LINUX的话可以
    crontab -e30 6 * * * (. /etc/profile;/home/root/cron1.sh)每天6点30分执行cron1.sh
      

  2.   

    对呀,若是Unix/Linux的话就加到crontab中;
    若是windows的话试试计划任务功能。
      

  3.   

    我非常同意skyyoung(路人甲)和ghw(大浪淘沙)的意见,这是一种非常好的方法,还有一种就是做一个deamon线程达到目的,但是你要保证必须有一个非deamon线程没有退出。 
      

  4.   

    package test;/**
     * Title:
     * Description:
     * Copyright:    Copyright (c) 2001
     * Company: TCL
     * @author  tony.郑
     * @version 1.0
     */
     /**
      * 此程序的作用是,在某段时间之后开始运行 TimeTask ,也就是 tt 线程.
      * 注意,因为 Timer对象的存在,程序需加上 System.exit(1)才能退出
      * 是这样的,Timer 对象的构造器包含了 Thread.start()
      *
      */
    import java.util.*;
    public class TimerTest {  public TimerTest() {
      }
      public static void main(String args[]){
        Timer t = new Timer();
        Tt task = new Tt(t);
        System.out.println("start");    try{
          t.schedule(task,1000);  //一秒后运行 task
        }
        catch (Exception e){
          System.out.println(e);
        }
      System.out.println("end ??");
      }
    }
    class Tt extends TimerTask{
      Timer t;
      public Tt(Timer t1){
        t=t1;
      }
      public void run(){
        System.out.println("run");
        System.out.println("end?");
        t.cancel();                     //这样来结束 Timer 的生命
        //System.exit(1);
      }
    }
      

  5.   

    解决了:
        GregorianCalendar gc = new GregorianCalendar(2001, 11, 7, 18, 0);
        java.util.Date myDate = gc.getTime();
        Timer timer = new Timer();
        timerTask = new TimerTask(){
          public void run(){
            System.out.println("done");
            }
          }
        };
        timer.schedule(timerTask ,myDate);