Libraryless. Click here for Pure Java version (478L/4K/13K).
// Syntax: thread "bla" { doSomething(); } // Also: thread var { doSomething(); } // Short for: new Thread("bla) { public void run() { doSomething(); }}.start(); !747 m { p { L<S> tok = javaTok(loadMainJava()); for (int i = 0; i < 100; i++) { int idx = findCodeTokens(tok, "thread", "*", "{"); if (idx < 0) break; int j = findEndOfBracketPart(tok, idx+4); S tName = tok.get(idx+2); S var = "_t_" + i; S pre = "{ Thread " + var + " = new Thread(" + tName + ") {\n" + "public void run() {\n" + "try"; S post = "} catch (Exception _e) {\n" + " throw _e instanceof RuntimeException ? (RuntimeException) _e : new RuntimeException(_e); } }\n};\n" + var + ".start(); }"; tok.set(idx, pre); tok.set(idx+2, ""); tok.set(j-1, post); } saveMainJava(join(tok)); } }
Began life as a copy of #721
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001362 |
Snippet name: | Named thread: thread "bla" { |
Eternal ID of this version: | #1001362/1 |
Text MD5: | 076d9ceae50fbb2ca872f827ecf2fd49 |
Transpilation MD5: | e1a3af5563f17c04636eb03ea301b282 |
Author: | stefan |
Category: | |
Type: | JavaX translator |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-07-24 14:23:14 |
Source code size: | 928 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 620 / 2506 |
Referenced in: | [show references] |