如何理解如下代码会造成DeadLock
1 | import java.util.concurrent.ArrayBlockingQueue; |
output
1 | Shuai:Junlan has bowed to me! |
Conclusion
- 类的实例对类中所有的synchronized方法都持有锁;(表述不够官方)
1 | import java.util.concurrent.ArrayBlockingQueue; |
output
1 | Shuai:Junlan has bowed to me! |
Conclusion
此方式只需要重写Thread类中的run()方法即可,示例如下:
1 | /** |
Update your browser to view this website correctly. Update my browser now