I wrote up an implementation of this in Java that uses a CountDownLatch to kick off all the sleeper threads simultaneously, then I fine-tuned the delay multiplier to I think 15 ms. I subtracted the min value from the sleep time so you could quickly sort numbers that range from, say, 1,000,000,000 to 1,000,000,100. A very common real world use case!
View all comments
Show parent comment
1
u/warmCabin Aug 11 '20
I wrote up an implementation of this in Java that uses a CountDownLatch to kick off all the sleeper threads simultaneously, then I fine-tuned the delay multiplier to I think 15 ms. I subtracted the min value from the sleep time so you could quickly sort numbers that range from, say, 1,000,000,000 to 1,000,000,100. A very common real world use case!