There's no statement that would create a new random number in the loop, that's why it loops endlessly.
I'm not sure why you're checking for "<"; from your description it sounds as if
you should be checking for "!=" - in which case the the second while statement is superfluous, because both numbers are guaranteed to be equal at that point.