标题: ----------银行账户存取钱例子---------- [打印本页] 作者: syusouki 时间: 2015-10-10 18:49 标题: ----------银行账户存取钱例子---------- public class Demo {
public static void main(String[] args) {
final Account acc = new Account();
new Thread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 100; i++) {
acc.getMoney(10000);
}
System.out.println("取钱结束!");
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 100; i++) {
acc.setMoney(10000);
}
System.out.println("存钱结束!");
}
}).start();