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.

static Set<S> isThreadRunnable_x_exclude = lithashset(
  "sun.nio.fs.WindowsNativeDispatcher.GetQueuedCompletionStatus0",
  "Java.lang.Thread.start0",
  "java.lang.Object.wait",
  "java.net.Inet6AddressImpl.lookupAllHostAddr",
  "java.io.FileInputStream.readBytes", // This usually means blocking
  "jdk.internal.misc.Unsafe.park",
  "sun.misc.Unsafe.park",
  "java.net.SocketInputStream.socketRead0",
  "java.net.PlainSocketImpl.socketConnect",
  "java.net.PlainSocketImpl.socketAccept",
  "sun.awt.X11.XToolkit.waitForEvents",
  "java.net.DualStackPlainSocketImpl.accept0",
  "org.jnativehook.GlobalScreen$NativeHookThread.enable",
  "java.lang.Thread.sleep",
  "sun.nio.ch.EPollArrayWrapper.epollWait",
  "com.ibm.lang.management.internal.MemoryNotificationThread.processNotificationLoop",
  "com.ibm.tools.attach.target.IPC.waitSemaphore",
  "sun.nio.ch.Net.poll",
  "sun.nio.ch.Net.accept",
  "sun.nio.ch.Net.connect0",
  "sun.nio.ch.EPoll.wait",
  "sun.nio.ch.SocketDispatcher.read0",
  "sun.nio.fs.LinuxWatchService.poll",
  "java.lang.ref.Reference.waitForReferencePendingList",
  "com.sun.java.accessibility.internal.AccessBridge.runDLL",
  "java.lang.ProcessHandleImpl.waitForProcessExit0");
  
sbool isThreadRunnable_x(StackTraceElement[] trace) {
  StackTraceElement e = first(trace);
  if (e == null) false; // Weird threads like "DestroyJavaVM"
  S s = e.getClassName() + "." + e.getMethodName();
  ret !isThreadRunnable_x_exclude.contains(s);
}
  
sbool isThreadRunnable_x(Thread t, StackTraceElement[] trace) {
  try object (Bool) vmBus_query isThreadRunnable_x(t, trace);
  
  if (t.getState() != Thread.State.RUNNABLE) false;
  ret isThreadRunnable_x(trace);
}

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: 701 / 831
Version history: 27 change(s)
Referenced in: [show references]