0 Replies Latest reply on Apr 7, 2006 3:00 AM by Tim Fox

    Utilising Compare and Swap in JDK1.5

    Tim Fox Master

      JDK1.5 (depending on platform) takes advantage of compare and swap instructions on modern processors to enable atomic conditional updates on references (see java.util.concurrent.atomic.ReferenceFieldUpdater.compareAndSet), enabling us to create concurrent data structures like queues that don't require mutual exclusion.

      This is like the difference between pessimistic locking (mutual exclusion) and optimistic locking (compare and set).

      (java.util.ConcurrentLinkedQueue already utilises this)

      I think we could use this in JBossMessaging if we detect JDK1.5 is running.