How to generate unique id
问题 How can we generate unique id's between two JVMs running at the same time? I think UUID uuid = UUID.randomUUID(); or UID uid = new UID(); is not enough. 回答1: You can concat to UUID server ID so UUID will be unique in all servers 回答2: See UUID docs, you can follow the link to find the rfc4122 explaining how the UUID will be generated. The last 48 bits are concerning your question, the spacial unique node identifier confirming that this value will be a Universally Unique IDentifier . 4.1.2.