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

对锁的一些认知有那些所的疑问 #175

Open
yngil opened this issue Sep 20, 2019 · 4 comments
Open

对锁的一些认知有那些所的疑问 #175

yngil opened this issue Sep 20, 2019 · 4 comments

Comments

@yngil
Copy link

yngil commented Sep 20, 2019

在表中加入一个同步状态字段,每次获取锁的是加 1 ,释放锁的时候-1,当状态为 0 的时候就删除这条记录,即释放锁。

实现重入锁时,并不能区分当前线程是否就是锁的持有者

insert into `t_lock`(`id`,`count`) values(1,1); 
update `t_lock` set `count` = `count`-1 where `id` = 1 and `count`>0;
@honwhy
Copy link

honwhy commented Jan 13, 2020

实现重入锁的话要多加字段吧

@AT-Fieldless
Copy link

感觉要加上两个字段表示机器名和线程名。

顺便我觉得这句话

每次获取锁的是加 1

是不是应该改成

每次获取锁的时候加1

@crossoverJie
Copy link
Owner

欢迎提交 pr 来修复这个问题。

@honwhy
Copy link

honwhy commented Jan 16, 2020

我也期待这个pr

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

4 participants