1. wait:
Causes current thread to wait until either another thread invokes the notify()
method or the
notifyAll()
method for this object
This method should only be called by a thread that is the owner of this object's
monitor
使当前线程放弃对象锁(等待?),直到其它线程为该对象调用notify()或notifyAll().
这个方法只能被拥有对象锁(监听器?)的线程执行。
2. notify,notifyAll
Wakes up a or all threads that are waiting on this object's monitor.
唤醒正在等待指定对象的锁的一个或所有线程。
-- 这样翻译也不知是否准确,括号内是按直译过来的意思。
3. 四种方式
1.static synchronized method(){}
2.sychronized(Class)
3.sychronized method(){}
4.sychronized() {}
4. 书上没说过的: Spin Lock (旋转锁)