Am 2015-02-06 um 22:13 schrieb Matthew Hall:
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.
How would you propose to use it?
I would still need a random number or do you recomment to use a static
one and simply increment during the lifetime of the application?
If so, thing might cause trouble in the future because I would probably
store the session information in a database for analysis issues and
woudl have collisions.
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]