java多线程点滴记录

java.lang.Thread.State描述了线程的六个状态:
NEW:A thread that has not yet started is in this state.
RUNNABLE:A thread executing in the Java virtual machine is in this state.
BLOCKED:A thread that is blocked waiting for a monitor lock is in this state.
WAITING:A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
TIMED_WAITING:A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.
TERMINATED:A thread that has exited is in this state.

使用vm监视器对sleep、wait、block监视的状态分别为休眠、等待、监视

sleep语义:我完成了我的时间片,在我休眠的这段时间不要给我分配时间片了
wait语义:我完成了我的时间片,在其他人唤醒我之间不要给我分配时间片了

ReentrantLock的同步器实现中,使用Unsafe.park()和Unsafe.unpark()阻塞和唤醒线程
同wait/notify在实现上有什么区别?

参考:
http://www.logicaltrinkets.com/wordpress/?p=153
http://www.docjar.com/docs/api/sun/misc/Unsafe.html#unpark(Object)
http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.State.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值