Skip to content

Instantly share code, notes, and snippets.

@smaugho
Last active April 29, 2017 12:21
Show Gist options
  • Save smaugho/85da5b103f681391d489058ee3b1b7cf to your computer and use it in GitHub Desktop.
Save smaugho/85da5b103f681391d489058ee3b1b7cf to your computer and use it in GitHub Desktop.
Multi-Threading Control with Actions
@Model
@Populate
List<Item> itemsList;
void sortAndUpdateItemsList() {
//This will run the following code in an Asynchronous (Background) Thread
$Background();
Collections.sort(itemsList,
new Comparator<Item_>(){
public int compare(Item_ item1, Item_ item2) {
return item1.getName().compareTo(item2.getName());
}
}
);
//This will run the following code in the Main (UI) Thread
$UIThread();
$Populate(itemsList);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment