Corrected and commented while-cycle in thread.