Managing shared state variable nature of the thread-safe access
A plurality of threads access state, and there is a write operation, if there is no need to synchronize # write, may be considered to be within the time interval is immutable, it is variable with respect to time
Serial is safe: the natural order to ensure that no intersection on time
The state of the three cases access is secure in
1. immutable (stateless)
2. Do not cross-thread
3. synchronized access
2,3 by limiting access (no intersection on time)
State security : invariants, preconditions, postconditions all meet
Atomicity: exclusive access state
Race: during execution concurrent operation may modify the constraint condition is lost, by avoiding mutex
If the state is changed concurrently, the atom is destroyed => atoms: the state is not changed concurrently => mutex
Are not independent variables involved in constraints between - operation state set by the need to update the same atom, either state may change constraint violations, race conditions extending
Locks: exclusive, serial
Internal lock (JVM record locks occupant (thread)), while ensuring atomicity and visibility reentrant (JVM count)
Lock seen as a necessary resource, mutex
The first layer of abstraction: a mutex lock (resources)
The second layer of abstraction: the maintenance of all non-independent variables, each of which access to the same are required to obtain a lock
The third layer of abstraction: the combined operation as an atomic operation, the entire exclusive operation, which contains a set of states
Visibility?