KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > test > UniqueSequenceGenerator


1 /**
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.test;
5
6 /**
7  * generates a sequence of unique ints for all kinds of test purposes.
8  * NOTE: this sequence starts from 0 and will be reset every time JVM is restarted.
9  */

10 public class UniqueSequenceGenerator {
11
12   public static UniqueSequenceGenerator getInstance() {
13     return theInstance;
14   }
15   
16   public synchronized int getNextInt() {
17     return this.currentValue++;
18   }
19   
20   private UniqueSequenceGenerator() {
21     super();
22   }
23
24   private static UniqueSequenceGenerator theInstance = new UniqueSequenceGenerator();
25   
26   private int currentValue = 84925;
27 }
28
Popular Tags