并发复习在回顾
归类:https://www.cnblogs.com/andlp/p/5886151.html
1,谁是谁的方法
object:wait,notify,notifyAll
Thread:静态sleep,interrupt
2,异常
- interrupt:中断该线程,当线程调用wait(),sleep(),join()或I/O操作时,将收到InterruptedException或 ClosedByInterruptException;
- condition.await()在lock.lock()前面调用,会有illegalMonitorStateException
3,新用法
Lock lock = new ReentranLock();
ReentrantLock,lock.lock()配合lock.unlock()相当于synchronize{ }
Condition condition = lock.newCondition();
condition.await(),condition.signal()