package ba; public class Tongbu implements Runnable{ int i=100; public void run(){ while(true){ sell(); } } public synchronized void sell(){ if(i>0){ System.out.println(Thread.currentThread().getName()+":"+i); i--; } } }
package ba; public class Tongbu implements Runnable{ int i=100; public void run(){ while(true){ sell(); } } public synchronized void sell(){ if(i>0){ System.out.println(Thread.currentThread().getName()+":"+i); i--; } } }