   calls."
   [function]
   `(fn [& args#]
-     (let [#^SynchronousQueue queue# (SynchronousQueue.),
+     (let [#^SynchronousQueue demand-queue# (SynchronousQueue.),   ; send demands to worker thread
+	   #^SynchronousQueue delivery-queue# (SynchronousQueue.), ; deliver results to consumer thread
 	   end# (atom false),
 	   eos# (Object.)]
-       (letfn [(~(symbol "yield") [x#] (.put queue# x#))]
+       (letfn [(~(symbol "yield") [x#]
+		(.put delivery-queue# x#)
+		(.take demand-queue#))]
 	 (.start (Thread. (fn []
+			    (.take demand-queue#)
 			    (apply ~function args#)
-			    (.put queue# eos#))))
+			    (.put delivery-queue# eos#))))
 	 (fn []
 	   (let [next# (if @end#
 			 eos#
-			 (let [new# (.take queue#)]
+			 (let [new# (do
+				      (.put demand-queue# 1)
+				      (.take delivery-queue#))]
 			   (if (= new# eos#)
 			     (reset! end# true))
 			   new#))]

                 5)
    -> ()

  [1] Actually, the first value is always computed due to
  implementation limitations (or limitations of my creativity, judge
  for youself).
  "
  [function & args]
  `(generate ((make-generator ~function) ~@args)))

;; NoSuchElementExceptions when there is nothing left to
;; generate. (See also iterators)

;; Generators

(defmacro- make-generator
