package desposit.money;
public class DespositMoney {
public static void main(String[] args) {
Customer c1 = new Customer("第一个顾客",3);
Customer c2 = new Customer("第二个顾客",10);
Customer c3 = new Customer("第三个顾客",5);
c1.start();
c2.start();
c3.start();
}
}
class Customer extends Thread{
private int time;
String s;
public Customer(String s,int time){
this.s = s;
this.time = time;
}
public void run(){
while(true)
{
synchronized(this){
if(time>0)
{
Total.sum+=100;
System.out.println(s+"存款100元,银行总共有存款"+Total.sum+"元");
try {
Thread.sleep(2000);
} catch (I