I'm trying to learn a bit about Clojure and it's concurrency features but 
I've hit an issue at an early point, where the same program exhibits 
different behavior if run within the REPL or from a regular file. This is 
the code I'm running:

(def foo (atom 0))

(pmap

    (fn [_] (swap! foo inc))

    (range 10000))

(println @foo) 


When I run this inside the REPL, the (pmap ...) returns the whole sequence 
with 10000 elements and the last line prints "10000", as expected. But when 
I put this code in a file and run it as one of
 

java -cp clojure-1.4.0.jar clojure.main swap.clj

java -jar clojure-1.4.0-slim.jar swap.clj 


then it will output "32" and the program won't terminate, I have to hit 
CTRL+C to get control back to the console. Am I doing something wrong here? 
I'm running Clojure 1.4.0 with Java 1.6.0_21 in Windows.

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