@Override
	public void run() {
		while(alive) {
			Socket s = this.socketPipe.read_buffer();
			if(s == null) {
				continue;
			}
			try {
				ObjectInputStream in;
				Object[] o;
				switch (state) {
				case MAPPING:
					in = new ObjectInputStream(s.getInputStream());
					o = (Object[]) in.readObject();
					in.close();
					if((op.Op)o[0] == op.Op.REGISTER) {
						String hostAddress = (String)o[1];
						Integer process = (Integer)o[2];
						System.out.println("host register: " + hostAddress + " - " + process);
						map.put(hostAddress, op.Op.REGISTER);
					} else {
						System.out.println("Invalid OpCode: " + o[0]);
					}
					break;
					
				case START_SORT:
					in = new ObjectInputStream(s.getInputStream());
					o = (Object[]) in.readObject();
					in.close();
					if((op.Op)o[0] == op.Op.SORTING) {
						String hostAddress = (String)o[1];
						System.out.println("host sorting: " + hostAddress);
						map.put(hostAddress, op.Op.SORTING);
					} else if((op.Op)o[0] == op.Op.COMPLETED) {
						String hostAddress = (String)o[1];
						System.out.println("host completed: " + hostAddress);
						map.put(hostAddress, op.Op.COMPLETED);
						if( this.terminateHosts() ) {
							this.t2 = System.currentTimeMillis();
							System.out.println("Terminated with: " + (double)(t2-t1)/1000 + "s");
							return;
						}
					} else {
						System.out.println("Invalid OpCode: " + o[0]);
					}
					break;

				default:
					System.err.println("Invalid State Code: " + state);
					break;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}