even if distance changes while loop is not terminated

#define trigPin 7
#define echoPin 6
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
long duration1, distance1;
duration1 = pulseIn(echoPin, HIGH);
distance1 = (duration1/2) / 29.1;
if (distance1 < 10)
{
Serial.println("the distance1 is less than 5");
delay(10000);
while (distance1 < 10)
{
Serial.println("the distancex is less than 5");
delay(500);
}
if(distance1 > 10)
{
Serial.println("the distance1 is greater than 5");
}

} }

Hi, welcome to the forum! Please have a look at How to use the forum and act accordingly. Like using code tags and telling the problem (what do you want and what happens).

(deleted)

while (distance1 < 10)
      {
        Serial.println("the distancex is less than 5");

That message is going to look really stupid when the distance is 9.