On Jan 21, 10:35 pm, tsuraan <tsur...@gmail.com> wrote: > What is the clojure idiom for running multiple (in this case IO bound) > functions simultaneously? My use case is the parallel activities are > coordinated, basically running in lockstep. I've been using (.start > (Thread. myfn)). It works, but I'm wondering if there's a better way. > The data shared between the threads is stored in an agent, which sort > of suggests send-off to me, but I can't find any reason to think that > send-off runs everything in parallel. Any thoughts would be welcome.
As a major convenience over starting separate threads by hand I would use "future". For each invocation future will run a given function on a different thread. You can then either dereference each future which will block until the function completes or ask if a future has completed with "future-done?". (You can also see futures used in the source of the pmap core function). See Sean Devlin's very helpful introduction to futures at: http://vimeo.com/8320428 It is not clear to me from your description if the agent is just aggregating data from the separate threads or is actually required for the threads to coordinate as they run, in the latter case you are in deeper water than I have swum in so far. -- 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