package com.css.dds.olddoctonewdoc;
import com.css.log.Logger;
public class TransThread implements Runnable
{
static Logger log = Logger.getLogger(TransThread.class) ;
/** 线程休眠时间间隔*/
static final long SLEEP_TIME = 5*1000 ;
boolean threadNotStopped = true; //线程停止标志位
//int i = 0 ;
Thread mainThread = null;
private static TransThread hos = null;
public void startThread()
{
mainThread = new Thread(this);
threadNotStopped = true;
mainThread.start();
}
public void stopThread()
{
threadNotStopped = false;
hos = null;
}
public void run ()
{
while (threadNotStopped)
{
try
{
log.info("BEGIN TRANS:") ;
DocTrans.transCMS (2) ;
log.info("END TRANS!") ;
}
catch (Throwable _t)
{
System.out.println("出错了");
log.error(_t) ;
}
try
{
Thread.sleep (SLEEP_TIME) ;
}
catch (Throwable _t)
{
log.error(_t) ;
}
}
}
public static TransThread getInstance()
{
return hos ;
}
public static void startScan ()
{
if (hos == null)
{
hos = new TransThread();
hos.startThread () ;
}
log.info(new java.util.Date() + " 民族旧CMS导入程序启动");
}
public static void stopScan ()
{
if (hos != null)
{
hos.stopThread () ;
}
log.info(new java.util.Date() + " 民族旧CMS导入程序关闭");
}
public static void main (String[] args)
{
startScan () ;
}
}