title: Clojure "repeatedly" makes "future" run sequentially
body: <p>While this snippet </p>
  
  <pre><code>(dorun 
    (map deref 
      (map #(future 
              (println % (Thread/currentThread))) 
           (range 10))))
  </code></pre>
  
  <p>prints 10 intermixed lines showing different threads:</p>
  
  <pre><code>0 #object[java.lang.Thread 0x5f1b4a83 Thread[clojure-agent-send-off-pool-26,5,main]]                                                                                                                           
  2 #object[java.lang.Thread 1 0x79dfba1f #object[Thread[clojure-agent-send-off-pool-28,5,main]java.lang.Thread]                                                                                                 
  3 4 #object[java.lang.Thread #object[java.lang.Thread 0x7ef7224f Thread[clojure-agent-send-off-pool-27,5,main]0x5f1b4a83 ]Thread[clojure-agent-send-off-pool-26,5,main]]                                       
  5                                                                                                                                                                                                              
  67  #object[java.lang.Thread #object[0x79dfba1f java.lang.Thread Thread[clojure-agent-send-off-pool-28,5,main]]0x77526645                                                                                      
   8 #object[java.lang.Thread #object[java.lang.ThreadThread[clojure-agent-send-off-pool-29,5,main] ]9 #object[java.lang.Thread 0xc143aa5 0x7ef7224f                                                             Thread[clojure-agent-send-off-pool-31,5,main]]Thread[clojure-agent-send-off-pool-27,5,main]]                                                                                                                       
  
  0x1ce8675f 0x379ae862 Thread[clojure-agent-send-off-pool-30,5,main]Thread[clojure-agent-send-off-pool-32,5,main]]]
  </code></pre>
  
  <p>as I would expect, the following snippet:</p>
  
  <pre><code>(dorun
    (map deref 
      (map #(future 
              (println % (Thread/currentThread))) 
           (repeatedly 10 #(identity 42)))))
  </code></pre>
  
  <p>produces 10 neatly aligned strings with the same thread:</p>
  
  <pre><code>42 #object[java.lang.Thread 0x1e1b7ffb Thread[clojure-agent-send-off-pool-39,5,main]]                                                                                                                              
  42 #object[java.lang.Thread 0x1e1b7ffb Thread[clojure-agent-send-off-pool-39,5,main]]                                                                                                                              
  42 #object[java.lang.Thread 0x1e1b7ffb Thread[clojure-agent-send-off-pool-39,5,main]]                                                                                                                              
  42 #object[java.lang.Thread 0x1e1b7ffb Thread[clojure-agent-send-off-pool-39,5,main]]                                                                                                                              
  42 #object[java.lang.Thread 0x1e1b7ffb Thread[clojure-agent-send-off-pool-39,5,main]]                                                                                                                              
  42 #object[java.lang.Thread 0x1e1b7ffb Thread[clojure-agent-send-off-pool-39,5,main]]                                                                                                                              
  42 #object[java.lang.Thread 0x1e1b7ffb Thread[clojure-agent-send-off-pool-39,5,main]]                                                                                                                              
  42 #object[java.lang.Thread 0x1e1b7ffb Thread[clojure-agent-send-off-pool-39,5,main]]                                                                                                                              
  42 #object[java.lang.Thread 0x1e1b7ffb Thread[clojure-agent-send-off-pool-39,5,main]]                                                                                                                              
  42 #object[java.lang.Thread 0x1e1b7ffb Thread[clojure-agent-send-off-pool-39,5,main]]                          
  </code></pre>
  
  <p>which clearly indicates that the futures are not run in parallel, but each in the same thread.</p>
  
  <p>This happens only with <code>repeatedly</code>, even if I realize the sequence with <code>doall</code> first, but vectors, <code>range</code>s or other sequences all result in parallel execution. </p>
  
  <p>Why is future dispatching to the same thread when <code>repeatedly</code> is used?</p>
  
  <p>Thanks!</p>