Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class TruckLoader implements Runnable {
private final LoadingBay bay;
private final Truck truck;
TruckLoader(LoadingBay bay, Truck truck) {
this.bay = bay;
this.truck = truck;
}
void loadTruck() {
while(true){
synchronized (this){
if(truck.isLoaded()) {
break;
} else {
truck.load(bay.unload());
}
}
}
}
@Override
public void run() {
loadTruck();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment