Java New synchronized

Source: Internet
Author: User

Java provides thesynchronizedKeyword forsynchronizing thread access to criticalsections. Because it can difficult to correctly writesynchronizedcode that ' s based onsynchronized, high-Level Synchronizers is included in the concurrency utilities. A countdown latch causes one or more threads to wait at a "gate" until Anotherthread opens ThisGate, at which point these other threads canContinue. It consists of acount and operations for"causing a thread to wait until the count reaches zero" and "decrementing the count." A cyclic barrier lets a set of threads wait forEach of the other to reach a common barrierpoint. The barrier is cyclic because it can being reused after the waiting threads is released. This synchronizer was useful in applications involving a fixed-size Party of threads Thatmust occasionally wait forEach of the other . An exchanger provides a synchronization point where threads can swap objects.  Each thread presents some object in entry to the exchanger ' s Exchange () method,matches with a partner thread, and receives Its partner ' s object onreturn. A semaphore maintains a set of permits forRestricting the number of threads thatcan access a limited resource. A thread attempting to acquire a permit when no permitsare available blocks until some other thread releases a permit. A phaser is a more flexible cyclic barrier. Like a cyclic barrier, a phaser lets a group ofthreads wait on a barrier; These threadsContinueAfter the last thread arrives. A phaser alsooffers the equivalent of a barrier action.  Unlike a cyclic barrier, which coordinates a fixednumber of threads, a phaser can coordinate a variable number of threads, which can registerat any time. To implement ThisCapability, a phaser uses phases and phase numbers.

Java New synchronized

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.