Regarding while loops:
Code:
while (2+2==4) {
System.out.println("I am still in autonomous");
}
If you're ever watching a match, and a Java/C++ team moves/does something in autonomous, but doesn't do anything during teleop... most of the time it's because they have a while loop checking for some condition that didn't occur that they thought would occur.
While loops are evil in robot code. Prefer not to use them (with a very few limited exceptions).
Threads are also evil (once again, with exceptions) in robot code and when used improperly can lead to difficult to diagnose bugs, prefer asynchronous constructs such as state machines instead.