日期:2014-05-20 浏览次数:21257 次
public void run() {
System.out.println(_threadName + " starts to run.");
float updatedValue = 0;
try {
Connection conn = DatabaseHelper.getConnection();
updatedValue = _account.getBalance() + _amount;
System.out.println(_threadName + " before:" + _account.getBalance());
System.out.println(_threadName + " sleep.");
Thread.sleep(_delayedTime);
System.out.println(_threadName + " wake up.");
System.err.println(_threadName + " 1 balance = " + _account.getBalance());
_account.setBalance(updatedValue);
System.err.println(_threadName + " 2 balance = " + _account.getBalance());
System.out.println(_threadName + " after:" + _account.getBalance());
conn.commit();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(_threadName + " stops running here.");
}