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

17
LINES

< > BotCompany Repo | #1016555 - interruptThread

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2517L/16K).

sbool interruptThread_verbose;

svoid interruptThread(Thread t) {
  if (t == null) ret;
  if (interruptThread_verbose) print("Interrupting thread " + t);
  
  // note reason in global map
  
  vm_threadInterruptionReasonsMap().put(t, getStackTrace());
  
  t.interrupt();
  URLConnection c = cast vm_generalSubMap("URLConnection per thread").get(t);
  if (c != null) pcall {
    print("Closing URLConnection of interrupted thread.");
    call(c, 'disconnect);
  }
}

Author comment

Began life as a copy of #1008281

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1016555
Snippet name: interruptThread
Eternal ID of this version: #1016555/8
Text MD5: ae64ee1ecca32630206891bbb655880c
Transpilation MD5: 4fdd6cc3c59e9bd4e04b918704b2356d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-30 19:51:17
Source code size: 481 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 201 / 249
Version history: 7 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1016555 & http://1016555.tinybrain.de