Skip to content

Instantly share code, notes, and snippets.

@micheljung
Created April 16, 2018 20:51
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 micheljung/b171b4e397306b5541ebd2fab7422538 to your computer and use it in GitHub Desktop.
Save micheljung/b171b4e397306b5541ebd2fab7422538 to your computer and use it in GitHub Desktop.
Reproduces https://bugs.openjdk.java.net/browse/JDK-8164446 JavaFX's addListener() isn't thread safe.
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.stage.Stage;
public class JDK8164446 extends Application {
@Override
public void start(Stage primaryStage) {
StringProperty stringProperty = new SimpleStringProperty();
new Thread(() -> {
while (true) {
stringProperty.addListener((observable, oldValue, newValue) -> noop());
}
}).start();
while (true) {
stringProperty.addListener((observable, oldValue, newValue) -> noop());
}
}
private static void noop() {
}
public static void main(String[] args) {
launch(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment