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

📄 boardloadthread.java

📁 天乙社区6.0是一套基于JAVA技术的网络虚拟社区
💻 JAVA
字号:
package com.laoer.bbscs.sys;

import javax.servlet.*;
import com.laoer.bbscs.business.service.*;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * <p>Title: TianYi BBS</p>
 * <p>Description: TianYi BBS System</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: LAOER.COM/TIANYISOFT.NET</p>
 * @author laoer
 * @version 6.0
 */

public class BoardLoadThread
    extends Thread {

  private static final Log logger = LogFactory.getLog(BoardLoadThread.class);

  public static BoardLoadThread instance;

  public synchronized static BoardLoadThread getInstance(ServletContext sc) {
    if (instance == null) {
      instance = new BoardLoadThread(sc);
    }
    return instance;
  }

  private boolean isRun = true;
  WebApplicationContext wac;

  public BoardLoadThread() {
  }

  public BoardLoadThread(ServletContext sc) {
    this.wac = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
  }

  public void run() {
    //SysInfo sysInfo = (SysInfo)this.wac.getBean("sysInfo");
    BoardList boardList = (BoardList) wac.getBean("boradList");
    if (SysInfo.getInstance().getBoardthread() > 0) {
      while (isRun) {
        try {
          this.sleep(SysInfo.getInstance().getBoardthread() * 60 * 1000);
          logger.info("Load board info.....");
          boardList.load();
        }
        catch (InterruptedException ex) {
          logger.error(ex);
          return;
        }
      }
      logger.info("board load thread stop");
      return;
    }
    logger.info("No board load thread");
    return;
  }

  public boolean isIsRun() {
    return isRun;
  }

  public void setIsRun(boolean isRun) {
    this.isRun = isRun;
  }

}

⌨️ 快捷键说明

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