我有以下 Java 程序:
public class A extends Thread {
int count;
@Override
public void run() {
while (true)
count++;
}
public static void main(String...strings){
A obj = new A();
obj.start();
System.out.println("The value of count is " + obj.count);
}
}
运行此程序时,输出为:(The value of count is 0
并且程序保持运行)。据我对线程的理解,它应该在无限循环中运行并且永远不会打印 0。任何人都可以帮助我理解这个程序的性质。