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

volatile 代码示例问题 #2

Open
liyiopener opened this issue Mar 2, 2022 · 0 comments
Open

volatile 代码示例问题 #2

liyiopener opened this issue Mar 2, 2022 · 0 comments

Comments

@liyiopener
Copy link

file:
src/main/java/com/example/concurrency/features/volatilecase/VolatileExample.java
line: 43
new Thread(aVolatile::stopThread).start();

该示例存在歧义,aVolatile::stopThread 会自动创建匿名 Runable 实现类对象,但这个对象与示例中 Volatile 实现类并不相等,
目的只是通过调用 stopThread 修改 volatile 变量而中止线程,43 行这种写法有很大的误导性

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

1 participant