Java AtomicLong getRAMUniqueID()

Here you can find the source of getRAMUniqueID()

Description

a simple counter which is garanteed to be unique ONLY within one instance of a virtual machine.

License

Apache License

Return

RAM unique ID

Declaration

public static long getRAMUniqueID() 

Method Source Code

//package com.java2s;
/**//from   w w w  .  java2  s . c o m
 * OLAT - Online Learning and Training<br>
 * http://www.olat.org
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); <br>
 * you may not use this file except in compliance with the License.<br>
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing,<br>
 * software distributed under the License is distributed on an "AS IS" BASIS, <br>
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
 * See the License for the specific language governing permissions and <br>
 * limitations under the License.
 * <p>
 * Copyright (c) 1999-2006 at Multimedia- & E-Learning Services (MELS),<br>
 * University of Zurich, Switzerland.
 * <p>
 */

import java.util.concurrent.atomic.AtomicLong;

public class Main {
    private static AtomicLong ramid;

    /**
     * a simple counter which is garanteed to be unique ONLY within one instance of a virtual machine. Best effort is taken to make it "globally unique" by instantiating
     * it by System.currentTimeMilis * 64, so that after a restart of the vm, the counter advances 64000 units per second which should be enough that that value is never
     * exceeded by the usage of that ID
     * 
     * @return RAM unique ID
     */
    public static long getRAMUniqueID() {
        return ramid.incrementAndGet();
    }
}

Related

  1. getMeUniqueString(Calendar cal)
  2. getMmapBufferUsage()
  3. getNativeSeed(Random rand)
  4. getNextTestIndexName()
  5. getNowMicrosUtc()
  6. getRandomTopicName()
  7. getSequenceNumber()
  8. getTempDirName()
  9. getTomorrowTime()