并发复习在回顾

归类: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()

  

posted on 2018-06-25 16:56  Kooing  阅读(93)  评论(0编辑  收藏  举报

导航