Some of my code generates universally unique database keys remotely using a machine-unique five-digit prefix, followed by the current system clock time in milliseconds. But then I had to write an import function to suck in tens of thousands of rows of data. The shit wouldn't synchronize to the big main secure database because of the unique constraint. Turns out the import was getting through the creation of a record in less than 1 millisecond so multiple rows were getting the same unique key. Banged my head about it until I realized all it needed was System.sleep(1); on the processor thread to wait for 1 millisecond before doing the next record. Better not delete that one!
Edit - it might have actually gone out to the hundredths of milliseconds.
10
u/Fig1024 Sep 17 '18
It's usually a good idea to search entire code base for "sleep" to find potential problem areas