Beispiel #1
0
  public static void main(String[] args) {
    TaskManager tm = new TaskManager();
    tm.setSearchURL(1000);
    tm.setNetDeepth(3);
    tm.setResultToDb(true);
    tm.setResultToFile(false);
    tm.setRecords(1000);

    PrintUtil.debug("设置的搜索容量为 " + tm.getSearchURL());
    PrintUtil.debug("设置的搜索深度为 " + tm.getNetDeepth());
    PrintUtil.debug(
        "结果保存在" + (tm.isResultToDb() ? "数据库中" : "  ") + (tm.isResultToFile() ? "文件中" : ""));

    // 保存文件
    Calendar c = Calendar.getInstance();
    int month = c.get(Calendar.MONTH) + 1;
    int day = c.get(Calendar.DAY_OF_MONTH);
    tm.setUrlfilename("url-" + month + "-" + day + ".txt");
    // 添加初始网址
    Address a = new Address();
    String url = "http://www.bilibili.com/";
    a.setUrl(url);
    a.setTitle(url);
    tm.initAdd(a);
    tm.start();
    // 计时器
    Timer t = new Timer();
    Counter counter = new Counter();
    counter.setTm(tm);
    t.schedule(counter, 3000, 5000);
  }
Beispiel #2
0
    @Override
    public void run() {
      // TODO Auto-generated method stub
      if (tm.isFinished()) {

        this.cancel();
      }

      PrintUtil.debug(
          "To do Tasks: "
              + tm.getTodoTasks()
              + "  Done Tasks: "
              + tm.getDoneTasks()
              + "  Current Threads: "
              + tm.getTaskThreads());
    }