int the final balance
? ? ? ? ? ? System.out.printf("Account : Final Balance: %f\n",account.getBalance());
? ? ? ? } catch (InterruptedException e) {
? ? ? ? ? ? e.printStackTrace();
? ? ? ? }
? ? }
}
结果,相同时间内,存与取执行后应该是相等的。如果我们在方法中不去使用synchronized关键字,那么得出的结果就不对了。
Account : Initial Balance: 1000.000000
Account : Final Balance: 1000.000000