Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package AirportPkg;
- class AirportCaller extends Thread {
- // create airplanes and call the airport
- private boolean canBeCalled;
- private Airport calledAirport;
- public AirportCaller(Airport calledAirport) {
- this.calledAirport = calledAirport;
- this.canBeCalled = calledAirport.isOpen();
- this.start();
- }
- public void stopCalling() throws InterruptedException {
- this.canBeCalled = false;
- this.join();
- }
- @Override
- public void run() {
- while (this.canBeCalled) {
- calledAirport.newCall(new Airplane(calledAirport));
- try {
- Thread.sleep(Utils.getNextCallTime());
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement