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

📄 scheduler.java.svn-base

📁 这个是我做j2ee培训时候自己整理和编写的设计模式的学习例子
💻 SVN-BASE
字号:
package org.hyq.observer1;

import java.util.LinkedList;
import java.util.Queue;

public class Scheduler extends Thread {

	private Queue<Action> actions = new LinkedList<Action>();
	private boolean isRunning = true;

	@Override
	public synchronized void run() {
		while (isRunning) {
			while (!actions.isEmpty()) {
				Action action = actions.remove();
				action.observer.doAction(action.observable, action.arg);
			}
			try {
				wait();
			} catch (InterruptedException ex) {
			}
		}
	}

	void addAction(Action action) {
		if (isRunning) {
			actions.add(action);
		}
	}

	void setStopFlag() {
		isRunning = false;
	}

}

⌨️ 快捷键说明

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