On Mon, Apr 26, 2010 at 5:55 PM, Meikel Brandmeyer <[email protected]> wrote: > Hi, > > On 26 Apr., 11:22, Per Vognsen <[email protected]> wrote: > >> Consider: >> >> (def as (lazy-seq (cons 1 bs))) >> (def bs (lazy-seq (cons 2 cs))) >> ;; ... >> (def zs (lazy-seq (cons 26 as))) >> >> Suppose you start two threads concurrently. The first forces 'as' and >> the second forces 'zs'. If the timing is just right, this can result >> in a deadlock: > > How? As far as I understand the code forcing as and zs are basically > independent tasks. seq does not recursively call into the rest. And > then you'd even need a circular structure (which is - I believe - what > you indicate with your "fill the next number" dots). Even a fixed > version of forcing wouldn't return anyway on such a structure, no?
The idea is to try to create a situation where a pair of LazySeqs, xs and ys, are interlinked in a cycle such that the first thread forces them in order xs, ys while the second thread concurrently forces them in order ys, xs. This could happen if thread #1 evaluates (doall (take 3 xs)) and thread #2 evaluates (doall (take 3 ys)). -Per -- 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
