Java Concurrent Programming Series (iii)-locks lock mechanism class

Source: Internet
Author: User

The lock in Java can be divided into "synchronous lock" and the lock inside the Juc package (locks package)

Synchronization Lock: That is, through the Synchronized keyword to synchronize, to achieve a mutually exclusive access to competing resources lock. Synchronization locks are already supported in Java version 1.0. The principle of a synchronous lock is that there is only one synchronization lock for each object, and the synchronization lock can be accessed by different threads together. However, at the same point in time, the synchronization lock can and can only be obtained by one thread. In this way, the thread that acquires the synchronization lock is able to perform CPU scheduling, which executes on the CPU, and no thread that acquires the synchronization lock must wait until the synchronization lock is acquired before it can continue to run.

Locks Package: The lock in the JUC package is more powerful than a sync lock, and it provides a framework for locks that allow more flexibility in the use of locks, which is more complex than native synchronization locks.

Java Concurrent Programming Series (iii)-locks lock mechanism class

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.