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).

1  
static <A> bool syncAdd(Collection<A> c, A b) {
2  
  if (c == null) false;
3  
  synchronized(collectionMutex(c)) { ret c.add(b); }
4  
}
5  
6  
static <A> void syncAdd(L<A> l, int idx, A b) {
7  
  if (l != null) synchronized(collectionMutex(l)) { l.add(idx, b); }
8  
}

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: 434 / 527
Version history: 3 change(s)
Referenced in: [show references]