⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runobject.java

📁 用于求解TSP(Traveling salesman problem
💻 JAVA
字号:
/**
 * Description: For a RunObject, it has some input pins, some control pins
 * (optional), and some output pins.
 *
 * @ Author        Create/Modi     Note
 * Xiaofeng Xie    May 22, 2000    xiaofengxie@tsinghua.org.cn
 *
 * @version 1.0
 * @Since MAOS1.0
 */
package Global.system;

import java.util.*;

import Global.define.*;

abstract public class RunObject extends ThreadObject {

  public RunObject() {}

/**
 * Run Object.
 */
  public void run() {
    synchronized(this){
      long time = System.currentTimeMillis();
      printTitle();
      try {
        pureRun();
        time = System.currentTimeMillis()-time;
        System.out.println("@ "+this.getKey()+"->Total "+((double)time/1000.0)+" second costed.");
      } catch(Exception e) {
        stop();
        System.out.println(e.getMessage());
      }
    };
  }

  public void pureRun() throws Exception {
    run_flag = FLAG_RUNNING;
    runObject();
    run_flag = FLAG_STOP;
  }

/**
 * Run Object.
 */
  abstract protected void runObject() throws Exception;

  protected void printTitle() {
    System.out.println("*********************************************");
    System.out.println("* [ "+getKey()+" ]");
    System.out.println("* "+Calendar.getInstance().getTime().toString());
    System.out.println("*********************************************");
  }
}

⌨️ 快捷键说明

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