Talk about thread sync lock and unlock

Source: Internet
Author: User

Lock can use Condition for scheduling between threads, it has better flexibility, and in an object can have multiple Condition (that is, Object monitor), the thread can be registered in a different Condition, so that can

A selective scheduling thread that is more flexible.

Synchronized uses the object itself notify, wait, notityall scheduling mechanism, equivalent to the entire object only a single condition (that is, the object itself) all the threads are registered on it, thread scheduling

After the time to dispatch all the registered threads, there is no choice, there will be a considerable problem.

The Synchronizer built on Aqs include reentrantlock,Semaphore,countdownlatch, Reetrantread writelock,futuretask , etc.

Talk about thread sync lock and unlock

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.