Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6275329

Add lazySet methods to atomic classes

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • core-libs

      Doug Lea writes

      "As probably the last little JSR166 follow-up for Mustang,
      we added a "lazySet" method to the Atomic classes
      (AtomicInteger, AtomicReference, etc). This is a niche
      method that is sometimes useful when fine-tuning code using
      non-blocking data structures. The semantics are
      that the write is guaranteed not to be re-ordered with any
      previous write, but may be reordered with subsequent operations
      (or equivalently, might not be visible to other threads) until
      some other volatile write or synchronizing action occurs).

      The main use case is for nulling out fields of nodes in
      non-blocking data structures solely for the sake of avoiding
      long-term garbage retention; it applies when it is harmless
      if other threads see non-null values for a while, but you'd
      like to ensure that structures are eventually GCable. In such
      cases, you can get better performance by avoiding
      the costs of the null volatile-write. There are a few
      other use cases along these lines for non-reference-based
      atomics as well, so the method is supported across all of the
      AtomicX classes.

      For people who like to think of these operations in terms of
      machine-level barriers on common multiprocessors, lazySet
      provides a preceeding store-store barrier (which is either
      a no-op or very cheap on current platforms), but no
      store-load barrier (which is usually the expensive part
      of a volatile-write)."
      ###@###.### 2005-05-24 17:04:20 GMT

            martin Martin Buchholz
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: