Generate a UUID in Java

Writing by on Wednesday, 27 of April , 2011 at 9:31 pm

Folks, look no further. java.util.UUID works great. I’ve tried the Axis’s UUIDGenFactory and and was NOT unique. 10 reps of 40 threads pounding simultaneously. At least, two or three of the forty were duplicates every time (only thirty seven were unique) Geeze!!! And I thought it was the synchronization.

java.util.UUID.randomUUID().toString(); // This works

Moreover, it uses SecureRandom number generator algorithms – so it is secure (in terms of predicting the next UUID etc.).

Leave a comment

Category: Java

No Comments

No comments yet.

Leave a comment

You must be logged in to post a comment.

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.