Users Pricing

forum

Home Forums Id Generation for multiple forms using java – MindStick

Id Generation for multiple forms using java

Anonymous User 2429 14 Oct 2013

Can anyone suggest if i use below code to generate id for my files, will it be unique always. As 100s forms create the form at same automatically which auto populate ids in ID textbox. So it should be thread safe and If i restart the application it should not ever repeat the id which already generated before the application stop anytime.

public static synchronized String generateIdforFile() 

{
     AtomicLong counter = new AtomicLong(System.currentTimeMillis()*1000);
         String val=Long.toString(counter.incrementAndGet(), 36);
    try
    {
    Thread.sleep(1);
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    return val;

And forms are getting the Id  using ClassName.generateIdforFile();


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md