Created
March 9, 2019 16:40
-
-
Save souenzzo/db84a96d1306da1fa3e45f741991df04 to your computer and use it in GitHub Desktop.
Run with java --source 11 Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Objects; | |
public class Main { | |
public static void main(String[] args) { | |
var foo = new Object() { | |
String x = "aa"; | |
}; | |
Thread t; | |
t = new Thread(() -> { | |
if (Objects.nonNull(foo.x)) { | |
System.out.println("não nulo! - " + foo.x); | |
for (var i = 0; i < 1e7; i++) { | |
} | |
System.out.println("não nulo? - " + foo.x); | |
} else { | |
System.out.println("é null"); | |
} | |
}); | |
t.start(); | |
for (var i = 0; i < 1e6; i++) { | |
} | |
foo.x = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment