I tried to play around with thread with these lines of code. It should
print the value of variable but it doesn't..

In emacs.
user> (def x 5)
#'user/x
user> x
5
user> (import [java.lang Thread])
java.lang.Thread
user> (.start (Thread. (fn [] (print x))))
nil


or with agent
user> (def foo (agent 0))
#'user/foo
user> foo
#<ag...@6af2f0d0: 0>
user> (send foo (fn[num] (do (println num) (inc num))))
#<ag...@6af2f0d0: 0>

I ran the exact same code in command-line and the thread could print
the output fine.

Clojure 1.1.0-master-SNAPSHOT
user=> (def foo (agent 0))
#'user/foo
user=> foo
#<ag...@194835fb: 0>
user=> (send foo (fn[num] (do (println num) (inc num) )))
0
#<ag...@194835fb: 0>

I installed everything from elpa, so I guess some of the component
might gone wrong. Any idea ?

thanks.

-- 
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