title: How expensive is Thread.sleep() in Java?
body: <p>I'm writing some code and wondering if its bad design to throttle a loop by calling <code>Thread.sleep(10)</code> at the beginning of each iteration. My other option is calling <code>Thread.sleep</code> fewer times at longer intervals but that is not optimal to what I'm coding. Does anyone know if I should be concerned with the overhead of resuming/pausing a Java thread at very rapid intervals when using <code>Thread.sleep()</code>, is there another alternative I should be looking at? - Duncan Krebs</p>
  
  <p>Here is my use case in more detail: </p>
  
  <p>I have a back testing data feed that iterates through a large List of Quote objects and I want to throttle the speed at which the quotes are consumed so I can speed up or slow down time in my back test. For starters I don't see another option other than Thread.sleep(), if that is the case then I can either Sleep after each Quote is consumed for a very small time or batch consume a collection and then sleep before consuming the next batch. The rest of the framework I have for understanding the tick data operates best if I can throttle this consumption thread 1 quote at a time, hope this makes sense!</p>