Concurrent programming 20--Atomic variables and non-blocking synchronization mechanisms

Source: Internet
Author: User

Concurrent Programming 01--concurrenthashmap

Concurrent programming 02--blocking queues and producer-consumer patterns

Concurrent programming 03--latching countdownlatch and fence Cyclicbarrier

Concurrent programming 04--callable and future

Concurrent programming 05--completionservice:executor and Blockingqueue

Concurrent Programming 06--Task cancellation

Concurrent programming 07--interruption of task cancellation

Concurrent programming 08--task cancellation stop thread-based services

Concurrent programming 09--off of task cancellation Executorservice

Concurrent Programming 10--task cancellation "poison pill" object

Concurrent programming 11--Limitations of the shutdownnow of task cancellation and shutdown

Concurrent programming 12--use of the thread pool configuration threadpoolexecutor and Saturation policy

The overall architecture of the concurrent programming 13--thread pool

The principle of concurrent programming 14--thread pool

Two principles of concurrent programming 15--thread pool

Concurrent Programming 16--lock

Concurrent programming 17--using built-in conditional queues for a simple bounded cache

Concurrent programming 18--an explicit Conditon object

In-depth analysis of concurrent programming 19--abstractqueuedsynchronizer

Concurrent programming 20--Atomic variables and non-blocking synchronization mechanisms

Overview

The disadvantage of the 1th part of the lock

2nd part

Reference

The disadvantage of the 1th part of the lock

Java traditionally uses locks to achieve synchronization between threads. Each object has an internal lock (intrinsic lock), and the keyword synchronized implements the mutex of the lock. The Object.wait method actively discards the lock, and Method Object.notify (all) is used to wake the thread in the waiting. Use synchronized to ensure thread synchronization is correct, but it is also easy to cause thread blocking.

Volatile variables are a more lightweight synchronization mechanism than locks, but they only guarantee the visibility of the memory, not the atomic operation. ++i appears to be atomic, but actually takes the current value, increments it by one, and then writes back the update.

Concurrent programming 20--Atomic variables and non-blocking synchronization mechanisms

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.