                      :seeds (repeatedly nthreads next-seed)})
           tests))
 
-(defn- prf
+(def ^:private serializer (agent nil))
+
+(defn serialized
+  "Returns a function that calls f for side effects, async,
+   serialized by an agent"
+  ([f] (serialized f serializer))
+  ([f agt]
+     (fn [& args]
+       (send-off agt
+                 (fn [_]
+                   (try
+                    (apply f args)
+                    (catch Throwable t
+                      (.printStackTrace t)))
+                   nil))
+       nil)))
+
+(def prf
   "Print and flush."
-  [s]
-  (print s) (flush))
+  (serialized (fn [s]
+                (binding [*out* *err*]
+                  (print s)
+                  (flush)))))
+
+(def print-stack-trace
+  (serialized (fn [^Throwable t] (.printStackTrace t))))
+
+(def sprn (serialized prn))
 
 (defn dir-tests
   "Returns all tests in dirs"

        ret (reduce
             (fn [{:keys [failures iters nresults]} result]
               (when (:exception result)
                 (.printStackTrace ^Throwable (:exception result)))
               (if (:exception result)
                 (prn result)
                 (progress))
               {:failures (+ failures (if (:exception result) 1 0))
                :iters (+ iters (:iter result))


(ns clojure.test.generative.runner
  (:require
   [clojure.tools.namespace :as ns]
   [clojure.data.generators :as gen]
   [clojure.test.generative :as tgen]))
