@Override
	public synchronized void run(){

		if(myRequests.isEmpty()){
			this.writeLog("R"+id+" has finished!\n");
			building.checkCompletion();
			return;
		}

		Request next = myRequests.remove();
		this.setStartDest(next.getFrom(),next.getTo());

		Elevator e;
		if(to > from){
			this.writeLog("R"+id+" pushes "+"U"+from+"\n");
			e =	building.callUp(this);
		}
		else {
			this.writeLog("R"+id+" pushes "+"D"+from+"\n");
			e = building.callDown(this);
		}

		this.writeLog("R"+this.getID()+" has been assigned E"+e.getID()+"\n");

		synchronized(e){
			while((e.getFloor() != from) || !e.isOpen()){
				this.safeWait(e);
			}
		}

		if(!e.Enter(this)){
			try {
				Thread.sleep(100);
			} catch (InterruptedException e1) {
				e1.printStackTrace();
			}
			this.addRequestToFront(new Request(id,from,to));
			this.run();
		}

		synchronized(e){
			while(e.getFloor() != to || !e.isOpen()){
				this.safeWait(e);
			}
		}

		e.Exit(this);

		try {
			Thread.sleep(100);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}

		this.run();

	}