示例#1
0
  /**
   * 启动线程
   *
   * @return 启动结果
   */
  public synchronized Return start() {
    if (this.isRunning() == true) {
      return Return.OK;
    }

    intThread1 = new InternalThread1();
    intThread2 = new InternalThread2();
    bCanExit = false;

    intThread1.setThread(this);
    intThread2.setThread(this);

    while (true) {
      try {
        intThread1.start();
        break;
      } catch (Exception e) {
        sleep(10);
      }
    }

    while (true) {
      try {
        intThread2.start();
        break;
      } catch (Exception e) {
        sleep(10);
      }
    }

    return Return.OK;
  }
示例#2
0
  /** 停止线程 */
  public synchronized void stop() {
    if (intThread1 == null || intThread2 == null) {
      return;
    }
    stopProc();

    while (true) {
      try {
        intThread1.join();
        break;
      } catch (Exception e) {
      }
    }

    while (true) {
      try {
        intThread2.join();
        break;
      } catch (Exception e) {
      }
    }
  }
示例#3
0
 /*
  * 属性------------------------------------------------------------------ 本类中需要对外界开放的在本类中创建的成员变量对象在此处定义为属性
  * 属性一般可以通过Get和Set方法设定,必要时也可以加以简化实现,举例如下 //简化方式,只可用于可读写的传值对象 public string strName; //正常方式 protected string strName;
  * public string getName(){return strName;} public void setName(string strName){this.strName=strName;}
  * ---------------------------------------------------------------------
  */
 public boolean isRunning() {
   if (intThread1 == null || intThread2 == null) {
     return false;
   }
   return intThread1.isRunning() || intThread2.isRunning();
 }