Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

同一线程同一把锁重入时的问题 #30

Open
ipodtree opened this issue Sep 5, 2020 · 4 comments
Open

同一线程同一把锁重入时的问题 #30

ipodtree opened this issue Sep 5, 2020 · 4 comments

Comments

@ipodtree
Copy link

ipodtree commented Sep 5, 2020

String curentLock = this.getCurrentLockId(joinPoint,klock); currentThreadLock.put(curentLock,new LockRes(lockInfo, false));
加锁时,这里的key是线程id+锁名。当同一线程重入这把锁时,内层释放时:
// avoid memory leak private void cleanUpThreadLocal(String curentLock) { currentThreadLock.remove(curentLock); }
会把这把锁从map里remove掉,在外层再释放时,就拿不到锁信息了:
private void releaseLock(Klock klock, JoinPoint joinPoint,String curentLock) throws Throwable { LockRes lockRes = currentThreadLock.get(curentLock); if (lockRes.getRes()) { boolean releaseRes = currentThreadLock.get(curentLock).getLock().release(); // avoid release lock twice when exception happens below lockRes.setRes(false); if (!releaseRes) { handleReleaseTimeout(klock, lockRes.getLockInfo(), joinPoint); } } }
是否应该加上计数器支持重入性?

@1205747671
Copy link

@klboke 这个问题还解决么?

@klboke
Copy link
Contributor

klboke commented Nov 3, 2022

我记得解决了,最新代码试试呢

@1205747671
Copy link

最新的提交记录是19年,这个问题是20年,是不是没提交呀。

@klboke
Copy link
Contributor

klboke commented Nov 3, 2022

cb1cdd1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants