Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只找到了一种方法,可以为我提供所有活动线程的数量:
BTraceUtils.threadCount()
但是如何获取ID?我想知道调用方法(@OnMethod)时哪些线程处于活动状态。
由于不可能在 BTrace 脚本中使用循环,因此线程 ID 的数组或列表将没有任何用处。
您必须切换到不安全模式才能启用不安全功能(例如循环),并且当您处于不安全模式时,您可以使用标准 ThreadMXBean 方法来获取线程 ID。