你的程序改成如下:
public class Robot extends Thread{
private long interval = 60000*60*12; //12Сʱ public Robot(){
} public Robot(long interval){
this.interval = interval;
} public void run() {
try{
while(true){
sleep(interval);
action();
}
} catch (Exception e){}
} public void action(){
System.out.println("-----------------");
}    public static void main (String arg[]){
Robot newsRobot = new Robot(1000);
newsRobot.start();
}}
没问题,已经测试过了:)