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

wait调用描述是否有误 #24

Open
panhongan opened this issue Nov 2, 2019 · 0 comments
Open

wait调用描述是否有误 #24

panhongan opened this issue Nov 2, 2019 · 0 comments

Comments

@panhongan
Copy link

如果一个线程在同步块中调用了Object#wait方法, 会将该线程对应的ObjectWaiter从EntryList移除并加入到WaitSet中,然后释放锁。当wait的线程被notify之后,会将对应的ObjectWaiter从WaitSet移动到EntryList中。

个人理解是:wait调用必须在synchronized代码块里。在synchronized进入时候,就已经将ObjectWaiter从EntryList移除;所以当发生wait调用的时候,应该是直接将ObjectWaiter对象加入到WaitSet,然后释放锁,并没有从EntryList移除这一步。

@panhongan panhongan changed the title wait调用描述是否不正确 wait调用描述是否有误 Nov 2, 2019
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