91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

模擬實現多線程處理銀行的實時轉賬交易,代碼完整,可以完美運行~

資源截圖

代碼片段和文件信息

package?task12_23.UpgradeTransferAccount;

/**
?*?Created?by?QXY?on?2018/12/14.
?*/
public?class?Account?{
????private?String?id;
????private?float?balance;
????private?int?transanctionNum=0;

????private?boolean?available=true;

????public?String?getId()?{
????????return?id;
????}

????public?float?getBalance()?{
????????return?balance;
????}

????public?int?getTransanctionNum()?{
????????return?transanctionNum;
????}

????Account(String??idfloat?balance){
????????this.id?=?id;
????????this.balance?=?balance;
????}

????public?synchronized?void?checkavaialbe(){

????????while?(!available){
//????????????System.out.println(this.getId()+“?do?not?prepare?well!***“+Thread.currentThread().getName()+“:Please?wait~“);
????????????try?{
????????????????wait();
????????????}?catch?(InterruptedException?e)?{
????????????????e.printStackTrace();
????????????}
????????}
//????????System.out.println(Thread.currentThread().getName()+“:I?get?the?account:“+this.getId());
????????this.available?=?false;
????}

????public?synchronized?boolean?checkavaialbe(int?locknum){

????????if(locknum?==0)?{
????????????while?(!available)?{
//????????????????System.out.println(this.getId()?+?“?do?not?prepare?well!***“?+?Thread.currentThread().getName()?+?“:Please?wait~“);
????????????????try?{
????????????????????wait();
????????????????}?catch?(InterruptedException?e)?{
????????????????????e.printStackTrace();
????????????????}
????????????}
//????????????System.out.println(Thread.currentThread().getName()?+?“:I?get?the?account:“?+?this.getId());
????????????this.available?=?false;
????????????return?true;
????????}else?{
????????????if(!available)?{
//????????????????System.out.println(Thread.currentThread().getName()?+?“?failed?to?lock?the?account:“?+?this.getId()?+?“:I?will?quit~“);
????????????????return?false;
????????????}else?{
//????????????????System.out.println(Thread.currentThread().getName()?+?“:I?get?the?account:“?+?this.getId());
????????????????this.available?=?false;
????????????????return?true;
????????????}
????????}
????}

????public?synchronized?void?balanceadd(float?amount)
????{
????????this.balance?+=?amount;
????}

????public?synchronized?boolean?balancesub(float?amount)
????{
????????if(amount?>?this.balance)
????????????return?false;
????????this.balance?-=?amount;
????????return?true;
????}

????public?synchronized?void?setAvailable(){
????????available=true;
//????????System.out.println(Thread.currentThread().getName()+“:I‘m?over~return?the?account:“+this.getId());
????????notifyAll();
????}

????public?synchronized?void?transanctionNumAdd()
????{
????????this.transanctionNum?++;
????}


}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????2733??2018-12-15?11:09??UpgradeTransferAccount\Account.java
?????文件????????2873??2018-12-15?11:30??UpgradeTransferAccount\MainBank.java
?????文件?????????341??2018-12-14?23:30??UpgradeTransferAccount\Transaction.java
?????文件?????3647799??2018-12-15?11:25??UpgradeTransferAccount\Transaction_record.txt
?????文件????????2885??2018-12-15?11:21??UpgradeTransferAccount\TransferThread.java
?????文件?????????864??2018-12-15?11:24??UpgradeTransferAccount\utils.java
?????文件???????15068??2018-12-04?16:07??UpgradeTransferAccount\多線程作業.docx
?????目錄???????????0??2018-12-15?11:43??UpgradeTransferAccount\

評論

共有 條評論