Java Concurrent Programming Practice Learning (2)--Combination of objects

Source: Internet
Author: User

    1. Apriori condition (precondition): Some methods contain a priori condition based on a state. For example, you cannot remove an element from an empty queue, and the queue must be in a non-empty state before the element is deleted. The operation of a state-based priori condition becomes a dependent state operation.
    2. In a single thread, if an operation fails to meet a priori condition, it can only fail, but in a concurrent program a priori condition may become true due to an operation performed by another thread.
    3. Various built-in mechanisms (including wait and notification mechanisms) waiting for a condition to be true in Java are closely associated with built-in locks.
    4. Ownership and encapsulation are always associated: an object encapsulates the ownership that it owns, and the object has ownership of its encapsulated state.
    5. When you publish a reference to a Mutable object, you no longer have exclusive control over it.
    6. Container classes often exhibit a form of "separation of ownership".
4.1 Designing Thread-safe classes

In the process of designing a thread-safe class, you need to include the following three basic elements:

  • Identify all variables that make up the state of the object
  • Finding the invariant conditions of constrained state variables
  • Establishing concurrent access management policies for object state

Java Concurrent Programming Practice Learning (2)--Combination of objects

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.