Sunday, January 02, 2005

Lock Free Programming

Java theory and practice: Going atomic "Until JDK 5.0, it was not possible to write wait-free, lock-free algorithms in the Java language without using native code. With the addition of the atomic variables classes in the java.util.concurrent.atomic package, that has changed. The atomic variable classes all expose a compare-and-set primitive (similar to compare-and-swap), which is implemented using the fastest native construct available on the platform (compare-and-swap, load linked/store conditional, or, in the worst case, spin locks). Nine flavors of atomic variables are provided in the java.util.concurrent.atomic package (AtomicInteger; AtomicLong; AtomicReference; AtomicBoolean; array forms of atomic integer; long; reference; and atomic marked reference and stamped reference classes, which atomically update a pair of values)."

See also, More flexible, scalable locking in JDK 5.0, Atomic Javadoc and an interesting article The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software.

And Java 1.5 Update 1 is out too.

No comments: