Created
November 22, 2019 09:51
-
-
Save jasongorman/ed9f6e667f86ed5fcb6fe06f0b665813 to your computer and use it in GitHub Desktop.
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
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