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

11
LINES

< > BotCompany Repo | #1012803 // initializedThreadLocal - takes a Class object; makes an instance for every thread

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

Libraryless. Click here for Pure Java version (2174L/14K).

static <A, B extends A> ThreadLocal<A> nuLike initializedThreadLocal(Class<B> c) {
  ret initializedThreadLocal(() -> nuInstance(c));
}

static <A> ThreadLocal<A> nuLike initializedThreadLocal(IF0<A> f) {
  ret new ThreadLocal<A>() {
    public A initialValue() {
      ret callF(f);
    }
  };
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012803
Snippet name: initializedThreadLocal - takes a Class object; makes an instance for every thread
Eternal ID of this version: #1012803/6
Text MD5: e87601719014250b51ab194daf351f38
Transpilation MD5: d5e23c0fbd6a1e3c476352d20063a0a4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-04 17:57:13
Source code size: 306 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 387 / 494
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1032508 - threadLocalWithDefault