smsgwj.java

来自「java支持的短信平台」· Java 代码 · 共 108 行

JAVA
108
字号
package com.khan.sms.cmpp2control;

import com.khan.file.Log;
import com.khan.util.common;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class SMSGWJ {
  public static String ProjectPath = System.getProperty("user.dir");

  public SMSGWJ() {
  }

  private void startFlag() {
    Log log = new Log("flag.out");
    log.logOut("flag");
    log.close();
  }

  private boolean isRun() {
    return Log.isFileExist("flag.out");
  }

  public static void main(String[] args) {
    common.Assert("debug:系统开始");
    Thread login_thread = null;
    Thread trans_thread = null;
    Thread mo_thread = null;
    Thread mt_thread = null;

    //System.out.println(ProjectPath);
    SMSGWJ smsgw = new SMSGWJ();
    smsgw.startFlag();

    while (smsgw.isRun()) {
      if (Cmpp2Login.flag) {
        if (null == login_thread) {
          login_thread = new Thread(new Cmpp2Login(), "cmpp_login");
          login_thread.start();
        }
      } else {
        common.sleep(1000);
        login_thread = null;
      }

      if (Transceiver.flag) {
        if (null == trans_thread) {
          trans_thread = new Thread(new Transceiver(), "cmpp_trans");
          trans_thread.start();
        }
      } else {
        common.sleep(1000);
        trans_thread = null;
      }

      if (Cmpp2MO.flag) {
        if (null == mo_thread) {
          mo_thread = new Thread(new Cmpp2MO(), "mo_thread");
          mo_thread.start();
        }
      } else {
        common.sleep(1000);
        mo_thread = null;
      }

      if (Cmpp2MT.flag) {
        if (null == mt_thread) {
          mt_thread = new Thread(new Cmpp2MT(), "mt_thread");
          mt_thread.start();
        }
      } else {
        common.sleep(1000);
        mt_thread = null;
      }

      common.sleep(1000);
    }

    Cmpp2Login.stopThread();
    common.Assert("debug:cmpp2login线程发送终止信号");
    common.sleep(1000);

    Transceiver.stopThread();
    common.Assert("debug:cmpp2Transceiver线程发送终止信号");
    common.sleep(1000);

    Cmpp2MO.stopThread();
    common.Assert("debug:cmpp2mo线程发送终止信号");
    common.sleep(1000);

    Cmpp2MT.stopThread();
    common.Assert("debug:cmpp2mt线程发送终止信号");
    common.sleep(1000);

    common.Assert("debug:系统停止");
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?