Home >类库下载 >java类库 >[JAVA Concurrent Programming Practice] Lock Sequence Deadlock

[JAVA Concurrent Programming Practice] Lock Sequence Deadlock

高洛峰
高洛峰Original
2016-11-17 13:39:151863browse

package cn.study.concurrency.ch10;

public class Account {
    private String staffAccount;    //账号
    private String passWord;    //密码
    private int balance; //账户余额
    
    public Account(int money) {
        this.balance = money;
    }
    
    public String getStaffAccount() {
        return staffAccount;
    }
    public void setStaffAccount(String staffAccount) {
        this.staffAccount = staffAccount;
    }
    public String getPassWord() {
        return passWord;
    }
    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }
    
    public void debit(int amount)
    {
        System.out.println("转出账户:" + amount);
    }
    
    public void credit(int amount)
    {
        System.out.println("转入账户:" + amount);
    }
    public int getBalance() {
        return balance;
    }
    public void setBalance(int balance) {
        this.balance = balance;
    }
    
}
rrree

Test results:

[JAVA Concurrent Programming Practice] Lock Sequence Deadlock

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn