初学者的问题
zhagy 2004-09-09 01:08:26 import java.lang.*;
import java.io.*;
import java.util.*;
public class test
{
private java.util.Timer timer;
public static void main(String[] args)
{
test t = new test();
try
{
t.getChatContent();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void getChatContent() throws Exception
{
timer = new Timer(true);
timer.schedule(new java.util.TimerTask()
{
public void run()
{
System.out.print("操作成功!");
}
},0,5000);
}
}
我想实现程序每隔5秒就执行
可是在编译通过后在cmd里用java test执行程序,该程序就执行了一次。
怎么解决。