我想知道下面的代码是否会run
无限直到server
停止?
public class Class1()
{
public static void main(String args[])
{
TimerTask task = new CacheThread();
Timer timer = new Timer();
timer.schedule(task, 1000,10000);
}
}
在这里,我调用了以下类中的任务:
package com.verizon.esupport.cache;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.TimerTask;
public class CacheThread extends TimerTask {//implements java.io.Serializable{
RetrieveHdrFtrContent rhf = RetrieveHdrFtrContent.getSingleInstance();
HeaderBean hdrbn = HeaderBean.getSingleInstance();
String header = "";
String footer= "";
String sHeader = "";
@Override
public void run() {
try{
// TODO Auto-generated method stub
HashMap headerm = new HashMap();
HashMap smallHeaderm = new HashMap();
HashMap footerMapm = new HashMap();
Date date = new Date();
header = rhf.headerContent().toString();
// headerm.clear();
// hdrbn.setLheaderMap(headerm);
headerm.put("header", header);
headerm.put("timeStamp", new Timestamp(date.getTime()));
hdrbn.setLheaderMap(headerm);
footer = rhf.footerContent().toString();
footerMapm.clear();
hdrbn.setLfooterMap(footerMapm);
footerMapm.put("footer", footer);
footerMapm.put("timeStamp", new Timestamp(date.getTime()));
hdrbn.setLfooterMap(footerMapm);
sHeader = rhf.smallHeader().toString();
smallHeaderm.clear();
hdrbn.setLsmallHeaderMap(smallHeaderm);
smallHeaderm.put("header", sHeader);
smallHeaderm.put("timeStamp", new Timestamp(date.getTime()));
hdrbn.setLsmallHeaderMap(smallHeaderm);
System.out.println("raising exception :: "+(1/0));
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("pls continue the task");
}
}
}
这会task
执行到server
停止吗?还让我知道是否exception
在一项任务中发生任何情况,执行者stop
会继续执行下一个任务吗?有人可以回答吗。。