@Override
	public void run() {

		setUp();

		try {

			while (true) {
				String line = scan.nextLine();
				Socket connection;
				ObjectOutputStream out;
				String[] arguments = line.split("\\W");
				if (arguments[0].equalsIgnoreCase(STOP_SIGN)) {
					connection = new Socket(SERVER_HOST, SERVER_PORT);
					ProcessMessage migrate = new ProcessMessage();
					migrate.setMessage(Message.STOP);
					out = new ObjectOutputStream(connection.getOutputStream());
					out.writeObject(migrate);
					connection.close();
					break;
				}

				if (arguments.length != NUM_ARGS) {
					printUsage();
				} else {
					Message message = mapping.get(arguments[0].toLowerCase());
					ProcessMessage task = new ProcessMessage();
					if (message == null) {
						printUsage();
						continue;
					}
					switch (message) {
					/*
					 * launch a process
					 */
					case LAUNCH:
						connection = new Socket(SERVER_HOST, SERVER_PORT);
						task.setMessage(Message.LAUNCH);
						task.setClassName(arguments[1]);
						task.setArgs(getArguments(task, scan));
						out = new ObjectOutputStream(
								connection.getOutputStream());
						out.writeObject(task);
						InputStream in = connection.getInputStream();
						int id = in.read();
						System.out
								.println("The assigned id for this process is: "
										+ id);
						connection.close();
						break;
					/*
					 * Migrate a process
					 */
					case MIGRATE:
						connection = new Socket(SERVER_HOST, SERVER_PORT);
						ProcessMessage migrate = new ProcessMessage();
						migrate.setMessage(Message.MIGRATE);
						migrate.setpId(Integer.parseInt(arguments[1]));
						out = new ObjectOutputStream(
								connection.getOutputStream());
						out.writeObject(migrate);

						connection.close();
						break;
					case SUSPEND:
						connection = new Socket(SERVER_HOST, SERVER_PORT);
						ProcessMessage suspend = new ProcessMessage();
						suspend.setMessage(Message.SUSPEND);
						suspend.setpId(Integer.parseInt(arguments[1]));
						out = new ObjectOutputStream(
								connection.getOutputStream());
						out.writeObject(suspend);
						connection.close();
						break;
					case RESTART:
						connection = new Socket(SERVER_HOST, SERVER_PORT);
						ProcessMessage restart = new ProcessMessage();
						restart.setMessage(Message.RESTART);
						restart.setpId(Integer.parseInt(arguments[1]));
						out = new ObjectOutputStream(
								connection.getOutputStream());
						out.writeObject(restart);
						connection.close();
						break;
					default:
						break;
					}
				}

			}
			scan.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}