In my system aircraft move randomly and when a condition is meet they send a document to the central station, this means that it can happen that some aircraft send a document at the point in time.
class SingleCentralStation{
public sendDocument(Document document){
//do something
}
}
class Spacecraft{
private SingleCentralStation singleCentralStation;
public Spacecraft(SingleCentralStation singleCentralStation){
this.singleCentralStation = singleCentralStation;
}
public sendDocumentToCentralStation(Document document){
singleCentralStation.sendDocument(document);
}
}
class App{
public static void main(String[] args) {
SingleCentralStation centralStation = new SingleCentralStation(); // singleton
Spacecraft spacecraft1 = new Spacecraft(centralStation);
Spacecraft spacecraft2 = new Spacecraft(centralStation);
Spacecraft spacecraft3 = new Spacecraft(centralStation);
Spacecraft spacecraft4 = new Spacecraft(centralStation);
Spacecraft spacecraft5 = new Spacecraft(centralStation);
// let's imagine that spacecrafts decide to send a document to central station all at the same point in time
spacecraft1.sendDocumentToCentralStation(new Document());
spacecraft2.sendDocumentToCentralStation(new Document());
spacecraft3.sendDocumentToCentralStation(new Document());
spacecraft4.sendDocumentToCentralStation(new Document());
spacecraft5.sendDocumentToCentralStation(new Document());
}
}
Questions:
- Multiple objects calling another method at the same time is possible?
- if not, why not?