Shridhar Raghavan wrote:Do they mean to say my Mac does not time 1ms as the standard 1ms and instead evaluates 1-2 ms in real time as it's 1ms. Or are they suggesting that it isnt precise?
Now with this mind, what are the limitations of unique currentTimeMillis as a standlone unique id generator? Should i club it with somthing more unique like a mac address or something.
Any other suggestions?
Hunter McMillen wrote:Is there something wrong with having a start ID of 1 and increment that ID every time to assign one?
Winston Gutkowski wrote:
Not unless the ID needs to be unique across JVM sessions. I presume this may not be enough since Shridhar already asked about MAC addresses.
Hunter McMillen wrote:That would be true, but it seemed to me that MAC addresses only got mentioned because of their uniqueness.
While speed in this context is an issue i can work around this by creating a large enough set of row ids before catering to any request right?
Any modern computer can generate millions of objects in a millisecond. So System.currentTimeMillis() is too slow.
Can i work around this using thread synchronisation and separate the row id generation routines from being thread aware? I mean when a new thread is spawned, each thread does not create a new row id, but rather fetches a row id from a collection of possible values. This fetching can be thread safe and the creation process of row ids can be separated.
If your program is multi-threaded and you have a multi-core CPU, then different cores might be creating objects at the same time
This is problematic. Will think on this. Any comments on the above?
If the system clock is adjusted
Shridhar Raghavan wrote:Hi,
Could someone clarify the doubts I raised.
Shridhar Raghavan wrote:First i desire to persist a long row id in the database and not an object identifier.
Secondly, at present i do not foresee requiring the id to be unique across machines. But rather than exploit sequences by the databases i would like to write a unique id generation algorithm. So i was searching for mechanisms to achieve that using present tools.