prova ad aggiungere un thread.sleep(1) dentro il while, dovrebbe funzionare.