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

8
LINES

< > BotCompany Repo | #1016979 - syncAdd - add & synchronize on collection

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2501L/16K).

static <A> bool syncAdd(Collection<A> c, A b) {
  if (c == null) false;
  synchronized(collectionMutex(c)) { ret c.add(b); }
}

static <A> void syncAdd(L<A> l, int idx, A b) {
  if (l != null) synchronized(collectionMutex(l)) { l.add(idx, b); }
}

Author comment

Began life as a copy of #1016969

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1016979
Snippet name: syncAdd - add & synchronize on collection
Eternal ID of this version: #1016979/4
Text MD5: 3cbd03c3aa1e47cb0fd8140a44dfb9b5
Transpilation MD5: f80e106db32fea370cbc3073ee37d692
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-22 12:46:04
Source code size: 253 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 184 / 210
Version history: 3 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1016979 & http://1016979.tinybrain.de