Home > Back-end >  Multithreaded learning, the art of concurrent Java programming of substance
Multithreaded learning, the art of concurrent Java programming of substance

Time:10-04

In a multi-threaded concurrent programming in synchronized and volatile plays an important role, volatile is lightweight
Synchronized, it ensures the Shared variables in the multi-processor development "visibility", visibility mean when a thread
To modify a Shared variable, another thread can read the change of value, if a volatile variable modifiers used properly
, it is better than the use of synchronized and execution cost is low, because it does not cause the thread context switching and scheduling, the
Wen will in-depth analysis on the hardware level Intel processor is how to realize the volatile, through in-depth analysis helps us to correctly
Use volatile variables,

Synchronized in multi-threaded concurrent programming has always been a veteran role, many will call it the heavyweight lock, but
As Java SE 1.6 after all kinds of optimization of synchronized, in some cases it is not so heavy, this article
Introduced in Java SE 1.6 getting the locks and the lock is released performance in order to reduce the consumption and the introduction of biased locking and lightweight
Lock and lock the storage structure and the upgrade process,
First look at the basis of using a synchronized synchronous: every object in Java can be used as a lock, the manifestation
For the following 3 kinds of forms,
Methods for normal sync, lock is the current instance object,
Methods for static synchronous, lock is the current Class of Class object,
For synchronous method, block, lock is Synchonized configuration object in brackets,
  • Related