Synchronization is achieved by obtaining an exclusive file locks on two specified lock files, and by using the files to store first "safe" timestamp value that the generator can use; alternating between one to use to ensure one of them always contains a valid timestamp. Latter is needed to guard against system clock moving backwards after UUID generator restart.
Note: this class will only work on JDK 1.4 and above, since it requires NIO package to do proper file locking (as well as new opening mode for {@link RandomAccessFile}).
Also note that it is assumed that the caller has taken care to synchronize access to method to be single-threaded. As such, none of the methods is explicitly synchronized here.
|
|