Skip to content

Instantly share code, notes, and snippets.

@gvsmirnov
Last active December 12, 2015 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gvsmirnov/4754061 to your computer and use it in GitHub Desktop.
Save gvsmirnov/4754061 to your computer and use it in GitHub Desktop.
Does JMM guarantee that the assertion passes?
class ValueHolder {
int first;
final int second;
ValueHolder(int first) {
this.first = first;
this.second = this.first;
}
}
//Thread 1
value = new ValueHolder(4);
//Thread 2
assert value.first == 4;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment