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

📄 processassistant.java

📁 请求排队系统1.1,一个简单的将请求队列后依次执行
💻 JAVA
字号:
package waitline;

/**
 * @author 李延庆
 * @version 1.1
 * @Date 2007-04-03
 */

public class ProcessAssistant implements Runnable {
	// the only instance of ProcessHost class
	private final ProcessHost ph;

	// the interval of the thread sleeping time(ms).
	private  int interval = 10000;

	// the switch to kill the thread of ProcessHost
	private boolean GoingRun = true;

	// initialize the instance of ProcessAssistant
	private ProcessAssistant(ProcessHost ph) {
		this.ph = ph;
		
	}

	public static ProcessAssistant getInstance(ProcessHost ph) {
		return new ProcessAssistant(ph);
	}

	public void run() {
		while (this.GoingRun) {
			try {
				Thread.sleep(this.interval);
			} catch (InterruptedException ie) {
				System.out.println(ie.getStackTrace());
			}
			
			ph.cleanTask();
		}

	}
	
	public void start(){
		Thread t=new Thread(this);
		t.start();
	}
	/*
	 * query the state of threads of ProcessHost
	 */
	public boolean isGoingRun() {
		return GoingRun;
	}

	/*
	 * set the key of thread f ProcessHost
	 */
	public void setGoingRun(boolean goingRun) {
		GoingRun = goingRun;
	}

	public int getInterval() {
		return interval;
	}

	public void setInterval(int interval) {
		this.interval = interval;
	}

}

⌨️ 快捷键说明

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