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

41
LINES

< > BotCompany Repo | #1011678 // isThreadRunnable_x - magically filters out threads waiting on sockets etc. // List of waiting methods is in here

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

Transpiled version (7539L) is out of date.

1  
static Set<S> isThreadRunnable_x_exclude = lithashset(
2  
  "sun.nio.fs.WindowsNativeDispatcher.GetQueuedCompletionStatus0",
3  
  "Java.lang.Thread.start0",
4  
  "java.lang.Object.wait",
5  
  "java.net.Inet6AddressImpl.lookupAllHostAddr",
6  
  "java.io.FileInputStream.readBytes", // This usually means blocking
7  
  "jdk.internal.misc.Unsafe.park",
8  
  "sun.misc.Unsafe.park",
9  
  "java.net.SocketInputStream.socketRead0",
10  
  "java.net.PlainSocketImpl.socketConnect",
11  
  "java.net.PlainSocketImpl.socketAccept",
12  
  "sun.awt.X11.XToolkit.waitForEvents",
13  
  "java.net.DualStackPlainSocketImpl.accept0",
14  
  "org.jnativehook.GlobalScreen$NativeHookThread.enable",
15  
  "java.lang.Thread.sleep",
16  
  "sun.nio.ch.EPollArrayWrapper.epollWait",
17  
  "com.ibm.lang.management.internal.MemoryNotificationThread.processNotificationLoop",
18  
  "com.ibm.tools.attach.target.IPC.waitSemaphore",
19  
  "sun.nio.ch.Net.poll",
20  
  "sun.nio.ch.Net.accept",
21  
  "sun.nio.ch.Net.connect0",
22  
  "sun.nio.ch.EPoll.wait",
23  
  "sun.nio.ch.SocketDispatcher.read0",
24  
  "sun.nio.fs.LinuxWatchService.poll",
25  
  "java.lang.ref.Reference.waitForReferencePendingList",
26  
  "com.sun.java.accessibility.internal.AccessBridge.runDLL",
27  
  "java.lang.ProcessHandleImpl.waitForProcessExit0");
28  
  
29  
sbool isThreadRunnable_x(StackTraceElement[] trace) {
30  
  StackTraceElement e = first(trace);
31  
  if (e == null) false; // Weird threads like "DestroyJavaVM"
32  
  S s = e.getClassName() + "." + e.getMethodName();
33  
  ret !isThreadRunnable_x_exclude.contains(s);
34  
}
35  
  
36  
sbool isThreadRunnable_x(Thread t, StackTraceElement[] trace) {
37  
  try object (Bool) vmBus_query isThreadRunnable_x(t, trace);
38  
  
39  
  if (t.getState() != Thread.State.RUNNABLE) false;
40  
  ret isThreadRunnable_x(trace);
41  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1011678
Snippet name: isThreadRunnable_x - magically filters out threads waiting on sockets etc. // List of waiting methods is in here
Eternal ID of this version: #1011678/28
Text MD5: 6fc18f091340008c742a37a0daec4389
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-09-21 17:17:39
Source code size: 1718 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 727 / 863
Version history: 27 change(s)
Referenced in: [show references]