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

📄 controltimer.java

📁 p2p仿真器。开发者可以工作在覆盖层中进行创造和测试逻辑算法或者创建和测试新的服务。PlanetSim还可以将仿真代码平稳转换为在Internet上的实验代码
💻 JAVA
字号:
package planet.util.timer;

import java.util.Iterator;
import java.util.Vector;

/**
 * This class has all its members statics to permit 
 * in a simulation envirionment controls
 * all timers and to inform them of the actual step of simulation.
 * @author <a href="mailto: jordi.pujol@estudiants.urv.es">Jordi Pujol</a>
 * Date: 05/05/2004
 */
public class ControlTimer {
	/**
	 * Actual step of simulation.
	 */
	public static int currentStep = 0;
	/**
	 * To contain all timers.
	 */
	private static Vector timers = null;
	
	/**
	 * Initialize the ControlTimer to permit adding Timers.
	 * It must be invoked before its fully use.
	 */
	public static void init() {
		timers = new Vector();
	}
	
	/**
	 * Adds the specified timer to current timers.
	 * @param timer SimulationTimer to advise each time.
	 */
	public static void add(SimulationTimer timer) {
		timers.add(timer);
	}
	
	/**
	 * Iterate for all active Timers to inform the actual step.
	 * @param step Actual simulation step.
	 */
	public static void currentStep(int step) {
		//nothing does if this step is passed.
		if (step <= currentStep) return;
		currentStep = step;
		Iterator it = timers.iterator();
		while (it.hasNext()) {
			SimulationTimer t = (SimulationTimer)it.next();
			//System.out.println("["+currentStep+"]: ControlTimer.currentStep(): timerTasks:\n"+t+"\n\n");
			t.currentStep(step);
		}
	}
	
	/**
	 * Sets the current step.
	 * @param step Current step
	 */
	public static void setCurrentStep(int step) {
		currentStep = step;
	}
}

⌨️ 快捷键说明

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