title: trying to break a while loop with a switch case inside switch case
body: <p>I am receiving some data from an USB component, component will send me continuous data, if I have received the data I have to stop reading the data myself and the component will not stop sending data, I am trying to break the loop if I received some key I tried using boolean, but it is not terminating the loop. </p>
  
  <pre><code> boolean shouldBreak = false;
  
      switch(msg.what)
      {               
  
      case USBAccessoryWhat:
      switch(((USBAccessoryManagerMessage)msg.obj).type) {
      case READ:
          if(accessoryManager.isConnected() == false) {
              return;
          }
          while(true) {
              if(accessoryManager.available() &lt; 2) {
                  break;
              }
  
              switch(commandPacket[0]){
                  case 0:
                      test = Integer.toString(commandPacket[0]) + ", " + Integer.toString(commandPacket[1]);
                      Test_one(test);
                  break;
                  case 1:
                      test = Integer.toString(commandPacket[0]) + ", " + Integer.toString(commandPacket[1]);
                      Test_one(test);
                  break;
                  case 2:
                      test = Integer.toString(commandPacket[0]) + ", " + Integer.toString(commandPacket[1]);
                      Test_one(test);
                      shouldBreak = true; // have to break here
                  break;
                  default:
                  break;
              } 
               if (shouldBreak) break; //To break this while
          }
          break;
  
      }
      break;
      }
  </code></pre>