title: Sleeping a thread inside an ExecutorService (Java/Clojure)
body: <p>I have a rather massive number of threads being created inside a clojure program:</p>
  
  <pre><code>(import '(java.util.concurrent Executors)) 
  (def *pool*   
    (Executors/newCachedThreadPool))
  
  (defn do-something []
    ; work
    Thread/sleep 200
    ; repeat)
  
  (dotimes [i 10000]
    (.submit *pool* do-something)) 
  </code></pre>
  
  <p>It's been a while between JVMs for me and I am basically wondering here if there is any argument against using sleep or yield inside the function that is being executed by the Executor? If I understand correctly, in this case, every one of my workers has it's own thread and therefore there should be no side effects.</p>
  
  <p>If the Executor is using a FixedThreadPool:</p>
  
  <pre><code>(Executors/newFixedThreadPool 1000)
  </code></pre>
  
  <p>Things become more complicated because threads will not be returned to the pool until their work is complete, meaning the other queued workers will take longer to complete if the threads are sleeping. </p>
  
  <p>Is my understanding of threading in this instance correct?</p>
  
  <p>(Note: I suspect my design is actually wrong, but just want to make sure I am on the right page)</p>