I first had the following function:
(defn check-concurrent2 []
(init "concurrent2")
(let [c1 (future (do-sequential 1 check-until 4))
c2 (future (do-sequential 2 check-until 4))
c3 (future (do-sequential 3 check-until 4))
c4 (future (do-sequential 4 check-until 4))]
@c1 @c2 @c3 @c4)
(deinit @max-factor))
But I did not like it, because it is 'difficult' to change. So I changed
it to:
(defn check-concurrent3 [number]
(init (format "concurrent3 with %d threads" number))
(let [concurrent-list (for [i (range 1 (+ number 1))]
(future (do-sequential i check-until
number)))]
(doseq [this-thread concurrent-list]
@this-thread))
(deinit @max-factor))
Is a little bit clearer and also allows me to do the following:
(def threads '(4 6 8 10))
(doseq [number threads]
(check-concurrent3 number))
Is this the right way to do things, or is there a better way?
--
Cecil Westerhof
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.