2010/12/3 Andreas Kostler <andreas.koestler.le...@gmail.com>: > Hi All, > May I cite an Author of a populer Clojure book: > > "If you find yourself wishing yourself to repeatedly check a work queue to > see if there's an item of work to be popped off, > or if you want to use a queue to send a task to another thread, you do *not* > want the PersistenQueue discussed in this section" > > Why do I not want to use clojure.lang.PersistentQueue for that purpose and > what would I want to use instead? > Can anyone fill me in please?
clojure.lang.PersistentQueue is a collection data structure with queue operations. It is persistent, so it lets you (and other threads) create modified versions of it with elements enqueued or dequeued in a thread-safe manner. java.util.concurrent.LinkedBlockingQueue[1] is not a persistent data structure. It is often used as a communication channel between threads, since it allows its operations to block (potentially with a timeout). One thread can dequeue (and block if the queue is empty) simultaneously as another thread can enqueue (and block if the queue is full) at the other end. It makes it easy to make programs in a producer-consumer style. // raek [1] http://download.oracle.com/javase/6/docs/api/java/util/concurrent/LinkedBlockingQueue.html -- 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