public void run() {
   while (true) {
     if (state.pendingCmd == true) {
       writeCmd = state.cmd;
       write(writeCmd);
       do {
         message = read();
       } while (!checkLen());
       checkMessage();
       state.pendingCmd = false;
     }
     try {
       sleep(5);
     } catch (Exception e) {
       System.out.println("Exception in overall sleep of stateUpdater");
     }
   }
 }