更新时间:1970-01-01 07:56:12
Java中的线程是协作的,这意味着您不能强制线程停止或暂停,而是向线程发送所需的信息和线程(=逻辑)本身完成.
Threading in Java is cooperative, which means you can not force the thread to stop or pause, instead you signal to the thread what you want and thread (= your logic) does it itself.
为此使用同步,wait()和notify().
Use synchronized, wait() and notify() for that.
synchronized
块内. wait()
. commonObject.notify()
.