notify() and notifyAll():

notify() and notifyAll():


notify() wakes up one thread and releases the lock. It is to send wake-up command to another one and only one thread that is in wait() status and is waiting for a notify command. After waking up, it will compete for the lock and as it is the only thread that was awake, it will get the lock and run. 


notifyAll() wakes up all waiting threads and releases the lock. It is to wake up other threads that are in wait() status and are waiting for a wake-up command (rather than the lock). After waking up, they will compete for the lock and the only one thread that gets the lock will run. Other threads are in ready state, not in wait() status (not waiting for wake-up command, but wait for lock). 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值