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

sclass SingleThread {
  bool running;
  Thread thread;
  
  void run(O r) { go(r); }
  
  synchronized bool go(final O runnable) {
    if (running) false;
    running = true;
    thread = startThread("Single Thread", r {
      try {
        callF(runnable);
      } finally {
        _done();
      }
    });
    true;
  }
  
  synchronized void _done() {
    running = false;
    thread = null;
  }
  
  synchronized bool running() { ret running; }
  
  synchronized Thread getThread() { ret thread; }
}

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