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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en