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

28
LINES

< > BotCompany Repo | #1001434 // MonoThread class - replaced by SingleThread or ReliableSingleThread

JavaX fragment (include)

static class MonoThread {
  Thread t;
  
  boolean runIfNotRunning(final Runnable r) {
    ret run(r);
  }
  
  synchronized boolean run(final Runnable r) {
    if (t == null) {
      t = new Thread() {
        public void run() {
          try {
            r.run();
          } catch (Throwable e) {
            e.printStackTrace();
          } finally {
            synchronized(MonoThread.this) {
              t = null;
            }
          }
        }
      };
      t.start();
      return true;
    } else
      return false;
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001434
Snippet name: MonoThread class - replaced by SingleThread or ReliableSingleThread
Eternal ID of this version: #1001434/1
Text MD5: 8709e1417fdeb4905603a235ef9c25b2
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-28 21:02:57
Source code size: 569 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 741 / 2032
Referenced in: #1001430 - Swing: Bots List
#1001435 - Swing: List VMs with programs [not so nice, shows IDs only]
#1001437 - swing-top: Bots table (developing)
#1001680 - swing-top 2: Bots table (with sub-bots)
#1001732 - Swing: List VMs (v2, with table, developing)
#1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)
#3000382 - Answer for ferdie (>> t = 1, f = 0)