http://docs.oracle.com/javase/tutorial/essential/concurrency/sync.html
thread interference memory consistency errors
class Counter { private int c = 0;
记不起来,在类中似乎有变量不能赋值的。
memory consistency errors:happens-before relationship
http://docs.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html
wo basic synchronization idioms: synchronized methods and synchronized statements.
When constructing an object that will be shared between threads, be very careful that a reference to the object does not "leak" prematurely. For example, suppose you want to maintain a List
called instances
containing every instance of class. You might be tempted to add the following line to your constructor:???
http://docs.oracle.com/javase/tutorial/essential/concurrency/locksync.html
Synchronization is built around an internal entity known as the intrinsic lock or monitor lock.