synchronized(this) {
while (true) {
this.wait();
}
}
(thanks to Carlos Heuberger. Exception handling omitted in the above code)
This will make the current thread wait on the monitor of the current class until someone calls notify()
, or forever.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…