Some OS's have a timer function that guarantees no 2 calls will return the same value, but for the rest of us, there's always that miniscule chance of a collision.
I just keep a keymanager
EJB that has a "dispenseKey" method. Since it's an EJB, transaction management and atomicity ensure that each call can be made to return a unique value, and also, since it's an EJB, the more you need it, the more often you'll find it in cache.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.