On Fri, Feb 06, 2015 at 04:54:25PM +0100, Michael Osipov wrote:
> This is what I did:
> this.internalId = RandomStringUtils.randomAlphanumeric(8);

When doing these types of tricks to assign transaction ID's or serial numbers 
to objects / log messages / etc., I'm more of a fan of using AtomicLong.

These are handled w/ hardware accelerated instructions, whereas Random 
consumes lots of CPU on a crypto or semi-crypto algorithm for something which 
doesn't actually need to be random, and introduces the possibility of 
collisions, which AtomicLong will prevent, even with many threads.

Matthew.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to