Hello,
I am using the following code to generate the random number. This code still gives the same number for multiple threads. I need better way of generating a random number with no ambiguity with multiple threads.
======================================================================
private
String generateRandomDocName() {
int nDigits = 9;
String rNumber = "";
rNumber = getRandomString ("1234567890ABCDEF", nDigits);
}
private String getRandomString (String charset, int length) {
Random rnd = new Random (System.currentTimeMillis());
StringBuffer sb = new StringBuffer(length);
int nChars = charset.length();
int rndIdx;
for (int i = 0; i < length; i++)
{
rndIdx = rnd.nextInt(nChars);
sb.append(charset.substring(rndIdx, rndIdx + 1));
}
return sb.toString();
}
===============================================================
Any inputs on this will help me.
Thanks and Regards,
Naresh