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 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

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: 433 / 525
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1016980 - syncClear - clear & synchronize on collection
#1016981 - syncAddIfNotThere - addIfNotThere & synchronize on collection
#1018749 - syncRemove - remove & synchronize on collection/map
#1019133 - syncPut - put & synchronize on map
#1029842 - csyncAdd - add & synchronize on collection in a concept