Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e8e76ecd07
Fetching contributors…

Cannot retrieve contributors at this time

file 29 lines (18 sloc) 0.986 kb

Unique Id generator

Based on which is in turn based on Twitter''s Snowflake project:

Generates unique ids based on the current epoch time, current machine identity, and a counter. The result are mostly ordered unique ids that require no synchronization between machines.

Compile and run

javac -cp .:./lib/uuid-3.2.1-SNAPSHOT.jar:./lib/commons-codec-1.6.jar src/uniq/
java -cp .:./lib/uuid-3.2.1-SNAPSHOT.jar:./lib/commons-codec-1.6.jar:src uniq.UniqueId


Single threaded:

$ time java -cp .:./lib/uuid-3.2.1-SNAPSHOT.jar:./lib/commons-codec-1.6.jar:src uniq.UniqueId > out

real        0m10.978s
user        0m6.234s
sys         0m4.262s

$ wc -l out 
516609 out

My super scientific analysis yields approximately 50 ids per millisecond.

Something went wrong with that request. Please try again.