public enum State { /** * Thread state for a thread which has not yet started. */ NEW, /** * Thread state for a runnable thread. A thread in the ru
wait和sleep区别:wait()方法必须在synchronized同步块或方法中 wait()方法会释放由synchronized锁上的对象锁,
wait和sleep区别:wait()方法必须在synchronized同步块或方法中 wait()方法会释放由synchronized锁上的对象锁,而sleep()则不会 由wait()方法形成的阻塞,可以通过针对同一个对象锁的synchronized作用域调用notify/notifyAll来唤醒; 而sleep()则无法被“唤醒”,其只能定时醒来或被interrupt()方法...
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号