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

28
LINES

< > BotCompany Repo | #1016693 // Many Sleeping Threads

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (14726L/102K).

1  
!7
2  
3  
sclass ManySleepingThreads extends DynPrintLog {
4  
  int number = 5;
5  
  transient JTextField tfNumber;
6  
  
7  
  transient L<Thread> threads = synchroList();
8  
  
9  
  JComponent visualize() {
10  
    ret northAndCenterWithMargins(centerAndEastWithMarginInbetween(withLabel("Number of threads:", tfNumber = jLiveValueTextField(dm_fieldLiveValue('number))),
11  
      jbutton("Make threads", rThread makeThreads)),
12  
      super.visualize());
13  
  }
14  
  
15  
  void makeThreads {
16  
    temp enter();
17  
    L<Thread> l = getAndClearList(threads);
18  
    print("Interrupting " + n2(l, "thread"));
19  
    interruptThreads(l);
20  
    l = null;
21  
    
22  
    if (tfNumber != null) setField(number := parseInt(gtt(tfNumber)));
23  
    for i to number: {
24  
      threads.add(startThread("Sleeper", r sleep));
25  
      print("Made thread " + (i+1) + "/" + number);
26  
    }
27  
  }
28  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016693
Snippet name: Many Sleeping Threads
Eternal ID of this version: #1016693/4
Text MD5: 9a8382808f4002d710d379922ff1262b
Transpilation MD5: 60959ebfe4c1b3287b77e22fd77f244c
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-28 12:54:59
Source code size: 839 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 319 / 444
Version history: 3 change(s)
Referenced in: [show references]