1. 程式人生 > >Java 定時執行函式

Java 定時執行函式

public class sendAutoServer extends HttpServlet{
	private static final long serialVersionUID = 8398634860666661954L;
	// private static Logger logger = Logger.getLogger(CLS_Business_Ms.class);
 	public void init(ServletConfig cfg) throws ServletException { 
        		super.init(cfg);   
	        
        		sendAutoThread sthread = new sendAutoThread(); 
        		sthread.start(); 
        		//ReceiveServer server =new ReceiveServer();   
    	}  
}

public class sendAutoThread extends Thread {
 	boolean isrun = true;
 	public void run(){
  		while(isrun){
			//do something;
 		}
 	}
}