I'm not quite sure what you're seeing. You might want to use the time macro to help.
Here's what I was able to do: user=> (time ((fn [] (let [f (future (#(do (Thread/sleep 5000) %) 5)) g 7] (+ g @f))))) "Elapsed time: 4975.917889 msecs" 12 Sean On Nov 25, 12:04 am, Hong Jiang <h...@hjiang.net> wrote: > Hi all, > > I'm new to Clojure and playing with small programs. Today I wrote a > snippet to figure out how future works: > > (defn testf [] > (let [f (future #(do > (Thread/sleep 5000) > %) > 5) > g 7] > (+ g @f))) > > (println (testf)) > > I'm expecting the program to sleep 5 seconds and then print 12 and > immediately terminate. However, the program seems to print out 12 > immediately, and it takes a long time (more like 50 seconds instead of > 5) to terminate. Am I missing something? > > Thanks. > --Hong -- 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