Go blocks are not the only thing that will do this. On a whole, thread locals are not propigated between threads in Clojure. However, dynamic vars are in some cases. Try this again with (future ...) and you should see the same behavior.
Behind the scenes dynamic vars are all stored in a single thread local, so it is quite easy to collect them all and pass them to a new thread. Not so easy with random ThreadLocals created by users. Timothy On Tue, Jul 29, 2014 at 7:42 PM, coltnz <[email protected]> wrote: > Do we expect this, seems inconsistent? > > cheers > Colin > > (def ^:dynamic dvar 1) > (def tl (ThreadLocal.)) > (.set tl 1) > (def _ (clojure.core.async/go > (println "Expect 1, ThreadLocal: " (.get tl)) > (println "Expect 1, Dvar: " dvar))) > > #'user/_ > Expect 1, ThreadLocal: nil > Expect 1, Dvar: 1 > > -- > 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. > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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.
