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

📄 idgenerator.java

📁 发布/订阅系统路由重配算法,可应用于ad hoc环境
💻 JAVA
字号:
/* * project: RebecaSim * package: util * file:    IDGenerator.java * version: 0.1 * date:    31.03.2005 *  * This software is part of the diploma thesis "Ein adaptives Brokernetz  * für Publish/Subscribe Systeme". */package util;/** * An <code>IDGenerator</code> provides <code>long</code> values  * convenient to build (unique) identifiers on. * As long as the value range is not exhausted all returned values are unique. * A new id-value is obtained by incrementing the last returned one. * @version 0.1 31.03.2005 * @author  Helge Parzyjegla */public class IDGenerator {		/** All new ID values are created incrementally based on this counter. */	private static long id;		/**	 * Creates a new <code>IDGenerator</code> instance with the first 	 * (returned) id-value initialized to <code>0</code>. 	 */	public IDGenerator() {		id = 0;	}		/**	 * Creates a new <code>IDGenerator</code> instance with the first 	 * (returned) id-value initialized to <code>value</code>.	 * @param value value of the first returned id 	 */	public IDGenerator(long value) {		id = value;	}		/**	 * Returns the next id-value, needed by the <code>ID</code> class to 	 * create a new <code>ID</code> object.	 * @return the next id-value	 */	public synchronized long getId(){		return id++;	}		/**	 * Resets the <code>IDGenerator</code> instance to <code>0</code>.	 */	public synchronized void reset() {		id = 0;	}		/**	 * Resets the <code>IDGenerator</code> instance to <code>value</code>.	 * @param value value of the next id after reset	 */	public synchronized void reset(long value) {		id = value;	}}

⌨️ 快捷键说明

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