I have a small test app that uses agents. After I wait for all agents
to complete, the app does not exit but hangs. I'm not sure what it's
waiting for. What is it waiting for, or what am I doing wrong?

(ns agent-test)

(defn do-something
  [a]
  (println "something!"))

(defn run-example
  []
  (println "hello")
  (let [agents (map #(agent %) (range 5))]
    (println agents)
    (println "sending do-something to agents")
    (doseq [a agents] (send a do-something))
    (println "waiting")
    (apply await agents)
    (println "all done")))

(run-example)

Output:
hello
(#<ag...@19c5466b: 0> #<ag...@fba0f36: 1> #<ag...@3caa4b: 2>
#<ag...@ed0220c: 3> #<ag...@26b496d: 4>)
sending do-something to agents
something!
something!
something!
something!
something!
waiting
all done
[Here, the app hangs. Why it it hanging?]

Jim
-- 
Jim Menard, http://www.io.com/~jimm/

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to