package cheshi1; public class Test extends Thread{ private static int a = 10; public void run(){ while (true){ if (a>0) { System.out.println(Thread.currentThread().getName()+"还有票,赶紧买吧,还有"+a+"张"); a--; }else { System.out.println("没票了,下次再来吧"); System.exit(0); } } } public static void main(String[] args) { Test test = new Test(); test.setName("窗口一"); test.start(); } }
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交