这是RedSpider社区成员原创与维护的Java多线程系列文章。
Geek Repo:Geek Repo
Github PK Tool:Github PK Tool
TeeMoCode opened this issue 4 years ago · comments
原图中acquire方法调用的tryAquire()方法,如果结果为true,自己中断线程;而查看AQS源码
public final void acquire(int arg) { if (!tryAcquire(arg) && acquireQueued(addWaiter(Node.EXCLUSIVE), arg)) selfInterrupt(); }
可以看到如果tryAcquire()结果为true,那么!tryAcquire()的结果为false,不会执行 selfInterrupt();而是执行获取到锁后的代码
#47 已修复,直接关闭。