Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

6
LINES

< > BotCompany Repo | #1019137 // syncPutIfNotThere - mapPut if key not there

JavaX fragment (include)

static <A, B> void syncPutIfNotThere(Map<A, B> map, A key, B value) {
  if (map != null && key != null && value != null) synchronized(map) {
    if (!map.containsKey(key))
      map.put(key, value);
  }
}

Author comment

Began life as a copy of #1008400

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019137
Snippet name: syncPutIfNotThere - mapPut if key not there
Eternal ID of this version: #1019137/1
Text MD5: a7860350586db0ac814b300f7856e196
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-24 21:44:36
Source code size: 209 bytes / 6 lines
Pitched / IR pitched: No / No
Views / Downloads: 368 / 375
Referenced in: [show references]