How to differentiate when wait(long timeout) exit for notify or timeout?

前端 未结 7 560
被撕碎了的回忆
被撕碎了的回忆 2020-12-15 02:58

Having this wait declaration:

public final native void wait(long timeout) throws InterruptedException;

It could exit by InterruptedExceptio

7条回答
  •  时光取名叫无心
    2020-12-15 03:40

    Exception is not thrown on notify and time out.

    I think it's better to rely on java.lang.concurrent package synchronisation objects instead of using Object.wait().

提交回复
热议问题