运行 ❯
获取您自己的
Java
服务器
×
更改方向
更改主题,深色/浅色
转到 Spaces
public class Main extends Thread { public static int amount = 0; public static void main(String[] args) { Main thread = new Main(); thread.start(); // Wait for the thread to finish while(thread.isAlive()) { System.out.println("Waiting..."); } // Update amount and print its value System.out.println("Main: " + amount); amount++; System.out.println("Main: " + amount); } public void run() { amount++; } }
正在等待...
Main: 1
Main: 2