KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > util > SequenceGenerator


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.util;
5
6 public class SequenceGenerator {
7
8   private long seq;
9
10   public SequenceGenerator() {
11     this(0);
12   }
13
14   public SequenceGenerator(long start) {
15     this.seq = start - 1;
16   }
17   
18   public synchronized long getNextSequence() {
19     return ++seq;
20   }
21
22   public synchronized long getCurrentSequence() {
23     return seq;
24   }
25 }
26
Popular Tags