@Override
	public void run() {
		try {
			while (true) {
				STCTransferMode mode = (STCTransferMode) in.readObject();
				System.out.println("get data");
				if(mode.equals(STCTransferMode.ModeChange)){
					ClientMode clientmode = (ClientMode) in.readObject();
					main.changeMode(clientmode);
					if (clientmode.equals(ClientMode.GenerateNumbers)) {
						System.out.println("compute");
						while(!main.verifyModeChange());
						for(ClientThread i: main.threads){
							synchronized(i){
								i.notify();
							}
						}
					} else if (clientmode.equals(ClientMode.Sleep)) {
						System.out.println("sleep");
					} else if (clientmode.equals(ClientMode.ReturnData)) {
						System.out.println("return");
						while(!main.verifyModeChange());
						System.out.println("returning");
						new ClientDataReturn(main);
					}
				} else if(mode.equals(STCTransferMode.Init)){
					System.out.println("init");
					sendData(CTSTransferMode.Init, new Integer(main.ID));
				} else if(mode.equals(STCTransferMode.Exit)){
					System.out.println("exiting");
					System.exit(0);
				}
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e){
			System.exit(0);
		}

	}