clojure - Why does this simple main method never return when run by leiningen? -


this piece of code returns immediately:

user=> (dorun (pmap + [1 2] [3 4])) nil 

however, when run same piece of code in main method using lein:

(ns practice.core)  (defn -main [& args]   (dorun (pmap + [1 2] [3 4]))) 

why never return?

interestingly, if replace pmap map, returns normally.

you need call shutdown-agents @ end of -main method.

(defn -main [& args]   (dorun (pmap + [1 2] [3 4]))   (shutdown-agents)) 

this mentioned on http://clojure.org/agents:

note use of agents starts pool of non-daemon background threads prevent shutdown of jvm. use shutdown-agents terminate these threads , allow shutdown.

pmap uses futures run on agent thread pool.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -