public class Tim {
public static void main(String[] args) {
// TODO Auto-generated method stub
final int time = 3000;
Runnable runnable = new Runnable(){
public void run(){
while (true){
System.out.println("自动任务");
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
Thread thread = new Thread(runnable);
thread.start();
}
}