public static void main(String[] args) { ThreadTest threadTest = new ThreadTest(); Thread thread = new Thread(threadTest,"窗口①"); Thread thread2 = new Thread(threadTest,"窗口②"); thread.start(); thread2.start();
} } //运行结果 //窗口② Sell a ticket:93 //窗口① Sell a ticket:93 //窗口② Sell a ticket:95 //窗口① Sell a ticket:95 //窗口① Sell a ticket:97 //窗口② Sell a ticket:97 //窗口② Sell a ticket:99 //窗口① Sell a ticket:99 //窗口② Sell a ticket:101