On Tue, Jan 25, 2011 at 9:45 AM, Michael Gardner <gardne...@gmail.com> wrote: > I have run across something else I don't understand about pmap. Why does the > following: > > (pmap (fn [_] (clojure.java.shell/sh "sleep" "10")) (range 32)) > > result in all 32 "sleep" processes being run at once? I thought pmap used n+2 > threads, where n is the number of processors/cores available (I have two > cores).
sh is asynchronous. It calls Runtime/exec, which launches the sleep as a separate process and immediately returns a Process object (which your pmap should be returning a seq of). It may produce n+2 Process objects at a time but it produces them all before the first of the asynchronous sleep processes finishes, so for a while all of the latter are running at the same time. -- 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