I'm not really sure I understand what you want to do here. If you want to access a Java class from Clojure, you can access it directly with the dot notation. If you are concerned about concurrency between your Java code and your Clojure code, this is no different from any concurrency in Java : you have to correctly publish your object from Java and make sure there are never two threads that try to write that variable at once.
Accessing Clojure from Java is generally much more painful than the other way around, except when you prepare for it on the Clojure side (genclass et al). >From what you're saying, I would advise you to take a look at java.util.concurrent.atomic.AtomicReference, which is sort of an atom in Java world. Then, from Clojure, if you have access to that reference, convert its content to a persistent data structure and manage it from Clojure from then on. Other than that, Clojure's Atoms are actually implemented in Java, so they should be usable, though not especially pleasant, since that was not their main purpose : https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Atom.java In particular, if you restrict yourself to the reset and compareAndSwap methods, you should be able to use a single atom to communicate effectively between Java and Clojure. Since I'm still not sure I understand your question, feel free to explain your problem further should I have missed the mark. On 9 April 2013 18:41, Timothy Washington <twash...@gmail.com> wrote: > Hi all, > > I have a polyglot project, comprising of a little Java and mostly Clojure > code. The Java class is a concrete callback for an external library. There > will be sub-second firing of that callback, and event map objects will get > pushed onto a list. > > From Clojure, I need to access that list in the callback. The problem is > that, in Clojure, we have STM (like refs) that can control access to the > data. If that data member is in Java, how can I control the access? From > Clojure, I could potentially access and flush the list, while the Java > callback is writing to it. > > Is there a better strategy here? Can Java access a STM ref in Clojure? How > might that work? > > > Thanks > Tim > > -- > -- > 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 > --- > 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 clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > -- -- 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.