I suspect you are talking about toplevel interaction. Prolog itself has
no notion about variable names whatsoever. Only the toplevel tries to be
a bit kind by finding the names you gave to the variables and reuse
these names when printing the results.
If you use a thread, you get new variables there. Only some tickery you
probably do not want to know about as a beginner can change that (roughly,
sending the answer back and have the toplevel unify the answer with the
original variables).
Cheers --- Jan