第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

為什么這個(gè)線程(WriteData)沒有做它的功能?

為什么這個(gè)線程(WriteData)沒有做它的功能?

慕村225694 2021-07-23 17:01:58
我正在練習(xí) Semaphore 類,我創(chuàng)建了兩個(gè)線程,其中一個(gè)將數(shù)據(jù)寫入“Shared”類中的 HashMap,另一個(gè)從 Shared 類中讀取數(shù)據(jù)。所以我的問題是,當(dāng)我讀取數(shù)據(jù)時(shí),它只顯示先前在 Shared 類中添加的數(shù)據(jù),而不是更新的數(shù)據(jù)。我不知道我在哪里失蹤了。如果是這樣,我應(yīng)該從“Writedata”類中讀取線程如何返回 HashMap。class Shared {    Map<String, Integer> hashmap = new HashMap<String, Integer>();    {        hashmap.put("kishore", 797979);        hashmap.put("nanesg", 8768787);        hashmap.put("mahesh", 842803);        hashmap.put("srikar", 7979980);    }    public void puthash(String name, Integer in, Map<String, Integer> hashmap) {        hashmap.put(name, in);    }    public Map<String, Integer> gethash() {        return this.hashmap;    }}這是它的輸出:writeThread trying to get permitread Thread trying to acquiring the permit write Thread acquires the permit write Thread relesing the permit read Thread acquires the permit reading data in hashmap, Here is the data: nanesg  : 8768787mahesh  : 842803kishore  : 797979srikar  : 7979980read Thread relesing the permit 為什么 WriteData 線程(特別是函數(shù))沒有添加數(shù)據(jù)。該功能有什么問題?
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 170 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)