public class SavingBox implements Runnable{
	double balance;
	public void run(){
		int count = 0;
		while(true){
			balance = balance+1000;
			count++;
			try{
				System.out.println(Thread.currentThread().getName()+"第"+count+"次存钱，存钱盒目前有"+balance+"元。");
				if(count==3){
					System.out.println(Thread.currentThread().getName()+"存了"+count+"次，本月存钱结束。");
					return;
			    }
				Thread.sleep(2000);
			}catch(InterruptedException e){
				System.out.println(e);
			}
		}
		
	}
}

class TestMain{
	public static void main(String[] args){
		SavingBox box = new SavingBox();
		Thread liLei = new Thread(box);
		liLei.setName("李雷");
		Thread hanMeiMei = new Thread(box);
		hanMeiMei.setName("韩梅梅");
		liLei.start();
		hanMeiMei.start();
	}
} 