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

28
LINES

< > BotCompany Repo | #1004705 // class SingleThread - drops triggers when it's already running one

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

Libraryless. Click here for Pure Java version (5438L/30K).

1  
sclass SingleThread {
2  
  bool running;
3  
  Thread thread;
4  
  
5  
  void run(O r) { go(r); }
6  
  
7  
  synchronized bool go(final O runnable) {
8  
    if (running) false;
9  
    running = true;
10  
    thread = startThread("Single Thread", r {
11  
      try {
12  
        callF(runnable);
13  
      } finally {
14  
        _done();
15  
      }
16  
    });
17  
    true;
18  
  }
19  
  
20  
  synchronized void _done() {
21  
    running = false;
22  
    thread = null;
23  
  }
24  
  
25  
  synchronized bool running() { ret running; }
26  
  
27  
  synchronized Thread getThread() { ret thread; }
28  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv

No comments. add comment

Snippet ID: #1004705
Snippet name: class SingleThread - drops triggers when it's already running one
Eternal ID of this version: #1004705/4
Text MD5: ecdea2e3503230ca11bf00c3180dfdb8
Transpilation MD5: 4f794a8d125adcbee07f67c5c78bf7e4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-13 04:23:15
Source code size: 531 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 821 / 3212
Version history: 3 change(s)
Referenced in: [show references]