Java Concurrency overview of security

Java Concurrency of learning content mainly from the "real Java Concurrent Programming," a book, this article is an overview.

 

Concurrent simplest explanation should be the interval where the execution time of the intersection of different tasks. Due to the intersection of time + shared variables, concurrency can create security issues.

From the perspective of the task, the mission needs to get the right effect; from the perspective of an object, the object needs to be the correct access.

The so-called right, or often said that the security thread, including the operation of an object, or a task to perform three aspects: the pre-conditions, invariants, post-conditions. These three constraints are related to the state, but the state is involved at different levels of abstraction.

 

State (shared variables) two semantic aspects of concurrency:

1. As part of an object, the object is subject to constraints

2. As part of the task, subject to the constraints of the task

These two semantic independently of one another, on demand lock

 

The book content can be summarized as follows:

Part I: to ensure the safety in the thread state, the state to ensure the safety of the subject combination (set as a special case) is introduced in a subject more constraints,

 

Part II: The task of decoupling with thread, the thread is essentially OS scheduling unit, after the introduction of the decoupling problem life cycle tasks, with the cancellation process error (timeout) of

 

Part IV: lock as a cause of obstruction, could lead to consequences, Lock provides timed, interruptible, non-block structure three functions.

      Conditions queue implemented as a pre-condition of:

 

Chapter One thread-safe (accidentally omitted from the first chapter hehe)

The first chapter of the book is about the concurrent threads from security point of view, if each thread is safe, the concurrency is safe.

Single security thread can be ensured by atomic, and atomic lock is achieved. Mutex lock to ensure thread execution, are arranged serially on each thread is essentially the same lock managed.

A lock to manage a set of threads serial execution.

Lock range by pre-conditions, the same constraint of scope postcondition constraints involved three state decision evidently become a set of shared variables and scope range.

This, from the thread - correctness constraints - state variables analyzed this idea began some out of control to start the second chapter, from the perspective of an object, the package state its operation, reduce the burden of thinking.

 

Chapter II shared objects

 

No, we finished first chapters to write, just look at the directory too little

Guess you like

Origin www.cnblogs.com/qmc2077/p/11431625.html