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

32
LINES

< > BotCompany Repo | #1012125 // Test cancelledThreads (OK)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (2262L/15K).

1  
!7
2  
3  
p {
4  
  Thread t = startThread("Whoopsie", r {
5  
    while licensed {
6  
      print("sleeping");
7  
      sleep(1000);
8  
      print("done sleeping");
9  
    }
10  
  });
11  
    
12  
  assertEmpty(cancelledThreads());
13  
  print("cancelling");
14  
  cancelThread(t);
15  
  assertNempty(cancelledThreads());
16  
  t = null;
17  
18  
  while licensed {
19  
    gc();
20  
    L<Thread> threads = cancelledThreads();
21  
    
22  
    // use System.err to clear reference to Whoopsie thread in x30.pout3
23  
    System.err.println(threads);
24  
    
25  
    if (empty(threads)) break;
26  
    threads = null;
27  
    sleep(100);
28  
  }
29  
  
30  
  assertEmpty(cancelledThreads());
31  
  print("OK");
32  
}

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: #1012125
Snippet name: Test cancelledThreads (OK)
Eternal ID of this version: #1012125/8
Text MD5: af96a6c8bff42983f52e154faf9890a2
Transpilation MD5: 353338fed4e1edd3d51ff1a00e90f124
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-20 11:56:42
Source code size: 632 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 411 / 859
Version history: 7 change(s)
Referenced in: [show references]