Object.wait 中JDK提供的doc文档 Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0). The current…
脏读 一个常见的概念.在多线程中,难免会出现在多个线程中对同一个对象的实例变量进行并发访问的情况,如果不做正确的同步处理,那么产生的后果就是"脏读",也就是取到的数据其实是被更改过的. 多线程线程安全问题示例 看一段代码: public class ThreadDomain13 { private int num = 0; public void addNum(String userName) { try { if ("a".equals(userName)) {…
From http://tutorials.jenkov.com/java-concurrency/synchronized.html By Jakob Jenkov A Java synchronized block marks a method or a block of code as synchronized. Java synchronized blocks can be used to avoid race conditions. The Java synchronized Ke…