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

13
LINES

< > BotCompany Repo | #1012674 // syncGet

JavaX fragment (include)

static <A> A syncGet(L<A> l, int idx) {
  if (l == null || idx < 0) null;
  synchronized(l) {
    ret idx < l(l) ? l.get(idx) : null;
  }
}

static <A, B> B syncGet(Map<A, B> map, A a) {
  if (map == null) null;
  synchronized(map) {
    ret map.get(a);
  }
}

Author comment

Began life as a copy of #1003807

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: #1012674
Snippet name: syncGet
Eternal ID of this version: #1012674/2
Text MD5: 02877e657120a43224225837a6bd8bdf
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-24 22:55:20
Source code size: 271 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 569 / 617
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1016969 - syncAddAll - addAll & synchronize on collection
#1016977 - syncEmpty - synchronized empty()
#1018751 - syncSize - l + sync
#1020733 - syncL - get size of collection or map while synchronizing on it. also, make a synchronized ArrayList