commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Hall <>
Subject Re: Re: [POOL2] Pooling mutable objects
Date Fri, 06 Feb 2015 21:13:57 GMT
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.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message