Libraryless. Click here for Pure Java version (1134L/8K/27K).
1 | !747 |
2 | !1001362 // named thread |
3 | |
4 | m { |
5 | static boolean free = true; |
6 | static new L<PaA> programsStarted; |
7 | |
8 | static class PaA { |
9 | S progID; |
10 | S[] arguments; |
11 | |
12 | *(S *progID, S[] *arguments) {} |
13 | *() {} |
14 | } |
15 | |
16 | p { |
17 | makeAndroid3("A multi-program VM. PID: " + getPID()); |
18 | sleep(); |
19 | } |
20 | |
21 | static synchronized S answer(S s, L<S> history) { |
22 | new Matches m; |
23 | |
24 | if (match3("please start program *", s, m)) { |
25 | if (!free) ret "Sorry, not free."; |
26 | |
27 | final S progID = formatSnippetID(unquote(m.m[0])); |
28 | final S[] arguments = new S[0]; |
29 | programsStarted.add(new PaA(progID, arguments)); |
30 | |
31 | // better call JavaX for translation in a single thread. |
32 | final Class theClass = hotwire(progID); |
33 | |
34 | // program may run in its own thread. |
35 | thread progID { |
36 | callMain(theClass, arguments); |
37 | } |
38 | |
39 | ret "OK."; |
40 | } |
41 | |
42 | if (match3("are you free to start a program?", s)) |
43 | ret free ? "Yes." : "No."; // free is usually true, but may be set to false by someone to stop this VM from starting more programs. |
44 | |
45 | if (match3("list programs started", s)) |
46 | ret structure(programsStarted); |
47 | |
48 | ret null; |
49 | } |
50 | } |
Began life as a copy of #1001361
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001363 |
Snippet name: | Multi-program VM |
Eternal ID of this version: | #1001363/1 |
Text MD5: | 99f55c3b323155ca78d6429fb2e4cedb |
Transpilation MD5: | 37fe4fd000eafee2d10f9f025c87d8e1 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-10-12 20:49:40 |
Source code size: | 1250 bytes / 50 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 603 / 628 |
Referenced in: | [show references] |