Source Code Cross Referenced for package-info.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » concurrent » atomic » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util.concurrent.atomic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


        /*
         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
         *
         * This code is free software; you can redistribute it and/or modify it
         * under the terms of the GNU General Public License version 2 only, as
         * published by the Free Software Foundation.  Sun designates this
         * particular file as subject to the "Classpath" exception as provided
         * by Sun in the LICENSE file that accompanied this code.
         *
         * This code is distributed in the hope that it will be useful, but WITHOUT
         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
         * version 2 for more details (a copy is included in the LICENSE file that
         * accompanied this code).
         *
         * You should have received a copy of the GNU General Public License version
         * 2 along with this work; if not, write to the Free Software Foundation,
         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
         *
         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
         * CA 95054 USA or visit www.sun.com if you need additional information or
         * have any questions.
         */

        /*
         * This file is available under and governed by the GNU General Public
         * License version 2 only, as published by the Free Software Foundation.
         * However, the following notice accompanied the original version of this
         * file:
         *
         * Written by Doug Lea with assistance from members of JCP JSR-166
         * Expert Group and released to the public domain, as explained at
         * http://creativecommons.org/licenses/publicdomain
         */

        /**
         * A small toolkit of classes that support lock-free thread-safe
         * programming on single variables.  In essence, the classes in this
         * package extend the notion of {@code volatile} values, fields, and
         * array elements to those that also provide an atomic conditional update
         * operation of the form:
         *
         * <pre>
         *   boolean compareAndSet(expectedValue, updateValue);
         * </pre>
         *
         * <p>This method (which varies in argument types across different
         * classes) atomically sets a variable to the {@code updateValue} if it
         * currently holds the {@code expectedValue}, reporting {@code true} on
         * success.  The classes in this package also contain methods to get and
         * unconditionally set values, as well as a weaker conditional atomic
         * update operation {@code weakCompareAndSet} described below.
         *
         * <p>The specifications of these methods enable implementations to
         * employ efficient machine-level atomic instructions that are available
         * on contemporary processors.  However on some platforms, support may
         * entail some form of internal locking.  Thus the methods are not
         * strictly guaranteed to be non-blocking --
         * a thread may block transiently before performing the operation.
         *
         * <p>Instances of classes
         * {@link java.util.concurrent.atomic.AtomicBoolean},
         * {@link java.util.concurrent.atomic.AtomicInteger},
         * {@link java.util.concurrent.atomic.AtomicLong}, and
         * {@link java.util.concurrent.atomic.AtomicReference}
         * each provide access and updates to a single variable of the
         * corresponding type.  Each class also provides appropriate utility
         * methods for that type.  For example, classes {@code AtomicLong} and
         * {@code AtomicInteger} provide atomic increment methods.  One
         * application is to generate sequence numbers, as in:
         *
         * <pre>
         * class Sequencer {
         *   private final AtomicLong sequenceNumber
         *     = new AtomicLong(0);
         *   public long next() {
         *     return sequenceNumber.getAndIncrement();
         *   }
         * }
         * </pre>
         *
         * <p>The memory effects for accesses and updates of atomics generally
         * follow the rules for volatiles, as stated in
         * <a href="http://java.sun.com/docs/books/jls/"> The Java Language
         * Specification, Third Edition (17.4 Memory Model)</a>:
         *
         * <ul>
         *
         *   <li> {@code get} has the memory effects of reading a
         * {@code volatile} variable.
         *
         *   <li> {@code set} has the memory effects of writing (assigning) a
         * {@code volatile} variable.
         *
         *   <li> {@code lazySet} has the memory effects of writing (assigning)
         *   a {@code volatile} variable except that it permits reorderings with
         *   subsequent (but not previous) memory actions that do not themselves
         *   impose reordering constraints with ordinary non-{@code volatile}
         *   writes.  Among other usage contexts, {@code lazySet} may apply when
         *   nulling out, for the sake of garbage collection, a reference that is
         *   never accessed again.
         *
         *   <li>{@code weakCompareAndSet} atomically reads and conditionally
         *   writes a variable but does <em>not</em>
         *   create any happens-before orderings, so provides no guarantees
         *   with respect to previous or subsequent reads and writes of any
         *   variables other than the target of the {@code weakCompareAndSet}.
         *
         *   <li> {@code compareAndSet}
         *   and all other read-and-update operations such as {@code getAndIncrement}
         *   have the memory effects of both reading and
         *   writing {@code volatile} variables.
         * </ul>
         *
         * <p>In addition to classes representing single values, this package
         * contains <em>Updater</em> classes that can be used to obtain
         * {@code compareAndSet} operations on any selected {@code volatile}
         * field of any selected class.
         *
         * {@link java.util.concurrent.atomic.AtomicReferenceFieldUpdater},
         * {@link java.util.concurrent.atomic.AtomicIntegerFieldUpdater}, and
         * {@link java.util.concurrent.atomic.AtomicLongFieldUpdater} are
         * reflection-based utilities that provide access to the associated
         * field types.  These are mainly of use in atomic data structures in
         * which several {@code volatile} fields of the same node (for
         * example, the links of a tree node) are independently subject to
         * atomic updates.  These classes enable greater flexibility in how
         * and when to use atomic updates, at the expense of more awkward
         * reflection-based setup, less convenient usage, and weaker
         * guarantees.
         *
         * <p>The
         * {@link java.util.concurrent.atomic.AtomicIntegerArray},
         * {@link java.util.concurrent.atomic.AtomicLongArray}, and
         * {@link java.util.concurrent.atomic.AtomicReferenceArray} classes
         * further extend atomic operation support to arrays of these types.
         * These classes are also notable in providing {@code volatile} access
         * semantics for their array elements, which is not supported for
         * ordinary arrays.
         *
         * <a name="Spurious">
         * <p>The atomic classes also support method {@code weakCompareAndSet},
         * which has limited applicability.  On some platforms, the weak version
         * may be more efficient than {@code compareAndSet} in the normal case,
         * but differs in that any given invocation of the
         * {@code weakCompareAndSet} method may return {@code false}
         * <em>spuriously</em> (that is, for no apparent reason)</a>.  A
         * {@code false} return means only that the operation may be retried if
         * desired, relying on the guarantee that repeated invocation when the
         * variable holds {@code expectedValue} and no other thread is also
         * attempting to set the variable will eventually succeed.  (Such
         * spurious failures may for example be due to memory contention effects
         * that are unrelated to whether the expected and current values are
         * equal.)  Additionally {@code weakCompareAndSet} does not provide
         * ordering guarantees that are usually needed for synchronization
         * control.  However, the method may be useful for updating counters and
         * statistics when such updates are unrelated to the other
         * happens-before orderings of a program.  When a thread sees an update
         * to an atomic variable caused by a {@code weakCompareAndSet}, it does
         * not necessarily see updates to any <em>other</em> variables that
         * occurred before the {@code weakCompareAndSet}.  This may be
         * acceptable when, for example, updating performance statistics, but
         * rarely otherwise.
         *
         * <p>The {@link java.util.concurrent.atomic.AtomicMarkableReference}
         * class associates a single boolean with a reference.  For example, this
         * bit might be used inside a data structure to mean that the object
         * being referenced has logically been deleted.
         *
         * The {@link java.util.concurrent.atomic.AtomicStampedReference}
         * class associates an integer value with a reference.  This may be
         * used for example, to represent version numbers corresponding to
         * series of updates.
         *
         * <p>Atomic classes are designed primarily as building blocks for
         * implementing non-blocking data structures and related infrastructure
         * classes.  The {@code compareAndSet} method is not a general
         * replacement for locking.  It applies only when critical updates for an
         * object are confined to a <em>single</em> variable.
         *
         * <p>Atomic classes are not general purpose replacements for
         * {@code java.lang.Integer} and related classes.  They do <em>not</em>
         * define methods such as {@code hashCode} and
         * {@code compareTo}.  (Because atomic variables are expected to be
         * mutated, they are poor choices for hash table keys.)  Additionally,
         * classes are provided only for those types that are commonly useful in
         * intended applications.  For example, there is no atomic class for
         * representing {@code byte}.  In those infrequent cases where you would
         * like to do so, you can use an {@code AtomicInteger} to hold
         * {@code byte} values, and cast appropriately.
         *
         * You can also hold floats using
         * {@link java.lang.Float#floatToIntBits} and
         * {@link java.lang.Float#intBitsToFloat} conversions, and doubles using
         * {@link java.lang.Double#doubleToLongBits} and
         * {@link java.lang.Double#longBitsToDouble} conversions.
         *
         * @since 1.5
         */package java.util.concurrent.atomic;

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.