Skip to content
Discussion options

You must be logged in to vote

The VarHandle takes precedence where its mode determines the memory semantics. When absent then the field's mode does, making it a volatile read or write. While not necessary if used consistently, its nice as a visual hint and added safety if accidentally missed since it uses the strongest memory mode. The JavaDoc is simply deferring to the more exhaustive explanation since the default memory mode is a volatile operation. You can experiment by adapting jcstress samples if you want to see that in action.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@severous
Comment options

@ben-manes
Comment options

@severous
Comment options

Answer selected by ben-manes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants