Last active
August 29, 2015 14:17
-
-
Save madhub/b5aed9bd66cdb8c079db to your computer and use it in GitHub Desktop.
UsingFXCollections
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 javafx.collections.FXCollections; | |
import javafx.collections.ListChangeListener; | |
import javafx.collections.ObservableList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.Future; | |
import java.util.concurrent.TimeUnit; | |
public class FxTest { | |
public static void main(String[] args) throws InterruptedException { | |
ObservableList<String> names = FXCollections.observableArrayList(); | |
names.addListener(new ListChangeListener<String>() { | |
@Override | |
public void onChanged(Change<? extends String> c) { | |
System.out.println("on Changed "+c); | |
} | |
}); | |
ExecutorService executorService = Executors.newSingleThreadExecutor(); | |
executorService.submit(() -> { | |
for (int i = 0; i < 10; i++) { | |
System.out.println("Adding ele"); | |
names.add("" + i); | |
} | |
}); | |
// TimeUnit.SECONDS.sleep(10); | |
executorService.shutdown(); | |
executorService.awaitTermination(10, TimeUnit.MINUTES); | |
System.out.println("Done"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment