- 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.
- 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.
- 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.
- Ownership and encapsulation are always associated: an object encapsulates the ownership that it owns, and the object has ownership of its encapsulated state.
- When you publish a reference to a Mutable object, you no longer have exclusive control over it.
- 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