eventdriver.java

来自「对于CPU线程调度的模拟」· Java 代码 · 共 35 行

JAVA
35
字号
package simcpu;

import java.util.PriorityQueue;

public class EventDriver {

	int now=0,last=0;
	SimSystem sys;

	public EventDriver(SimSystem sys) {
		super();
		this.sys = sys;
	}

	public int getNow() {
		return now;
	}
	
	PriorityQueue<Event> queue=new PriorityQueue<Event>();
	public void predict(Event e) {
		queue.add(e);
	}
	
	public void run() {
		while(queue.size()>0) {
			Event e=queue.poll();
			now=e.getTime();
			sys.run(now-last);
			last=now;
			e.handel();
		}
	}
	
}

⌨️ 快捷键说明

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