- class ChuangKou extends Thread
- {
-
- public static int piao = 100;
- ChuangKou(String name)
- {
- super(name);
- }
- public void run()
- {
- while(true)
- {
- if(piao>0)
- System.out.println(getName()+"......."+piao--);
- }
- }
- }
- class MaiPiao
- {
- public static void main(String[] args)
- {
- ChuangKou P1 = new ChuangKou("chuangkou1");
- ChuangKou P2 = new ChuangKou("chuangkou2");
- ChuangKou P3 = new ChuangKou("chuangkou3");
- P1.start();
- P2.start();
- P3.start();
- }
- }
复制代码 piao=100 是静态的 可是在执行的时候 为什么还会出现打印两次100的情况。不是输出完就自减过了么。
|
|