/**
 * @(#)file    SignThread.java
 * @(#)author  DaeJin Lee
 * @(#)version 1.0
 * @(#)date    Jun 10, 2005
 * @(#)since   JDK 1.4.2
 *
 * Copyright (c) www.dcchem.co.kr, Inc.
 * All rights reserved.
 * This software is the proprietary information of dcchem, Inc.
 */
package kr.co.udapsoft.common.commonSign;

import kr.co.hsnc.common.logger.Logger;

/**
 * 
 * @version 1.0
 * @author DaeJin Lee
 */
public class CommonSignThread extends Thread {

    private boolean IS_RUN = false;

    private long INTERVAL = 1000l * 120 * 1;

    private static CommonSignThreadBiz biz = null;

    protected CommonSignThread() {
        biz = new CommonSignThreadBiz();
    }

    /**
     * Thread 가동여부를 리턴
     * @return
     */
    public boolean isRun() {
        return this.IS_RUN;
    }
    
    /**
     * Thread Start
     */
    public void doStart() {
        if( !this.IS_RUN ) {
            this.IS_RUN = true;
            this.start();
        }
    }

    /**
     * Thread Stop
     */
    public void doStop() {
        if( this.IS_RUN ) {
            this.IS_RUN = false;
            super.interrupt();
        }
    }

    /* (non-Javadoc)
     * @see java.lang.Runnable#run()
     */
    public void run() {
        while(IS_RUN) {
            try {
                Thread.sleep(INTERVAL);
            }
            catch(InterruptedException ie) {
            }
            try {
                if( IS_RUN ) {
                    Logger.debug.println("hwenc.pcms.common.commonSign.CommonSignThread run.");
                    biz.doBiz();
                }
            }
            catch(Exception e) {
            	e.printStackTrace(System.out);
                Logger.err.printStackTrace(e);
            }
        }
    }
}