views:

119

answers:

1

When I run the following code it basically works how I intend it to, except that it hangs after the future is finished. What am I missing - some kind of "close agents/threads" call? How should I do this?

(def name-to-greet (promise))

(future
    (println "Hello," @name-to-greet))

(print "What is your name? ")
(flush)
(deliver name-to-greet (read-line))
+4  A: 

Futures use the agent thread pool, which uses non-daemon threads, which means Clojure won't shut down till you call (shutdown-agents). imho, this is bogus (see my comments here) and I've made suggestions that Rich said he would consider post-1.2 around this.

Alex Miller
Good point–I didn't think of that. Thanks, and good to know!
Isaac Hodes