Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created November 22, 2019 09: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 jasongorman/ed9f6e667f86ed5fcb6fe06f0b665813 to your computer and use it in GitHub Desktop.
Save jasongorman/ed9f6e667f86ed5fcb6fe06f0b665813 to your computer and use it in GitHub Desktop.
class BayLoader implements Runnable {
private final LoadingBay bay;
private final List<Parcel> parcels;
BayLoader(LoadingBay bay, List<Parcel> parcels) {
this.bay = bay;
this.parcels = parcels;
}
private void loadAll() {
while(true){
synchronized (this){
if(parcels.isEmpty()) {
break;
} else {
bay.load(parcels.get(parcels.size() - 1));
parcels.remove(parcels.size() - 1);
}
}
}
}
@Override
public void run() {
loadAll();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment