Hi guys I have the following.
class a extends Thread
{
public synchronized BigInteger getUniqueID()
{
BigInteger aUniqueID = new BigInteger(getUniqueKeyFromDatabase);
return aUniqueID;
}
}
class b extends a
{
public run()
{
BigInteger uniquieID = getUniqueID();
// store UniqueID in another database table with other stuff
}
}
And what I’m getting is duplicate unique id stored in the database table. I’m assuming because uniqieID is being changed in this multi threaded environment.
I’m obviously going horribly horribly wrong somewhere, I’m guessing I shouldn’t be returning the value in this way. Or should be defining uniqueID as new BigInteger based on the response from the getUniqueID method.
Any help would be greatly appreciated, as my fragile mind has been warped right now!
Cheers
Alan
BigIntegeris an (from the JavaDocs)So that rules out anyone mutating the BigInteger object. I’d look into
getUniqueKeyKeyFromDatabase