Search code examples
javabtrace

How to get all live thread IDs in btrace?


I've only found a method that gives me the number of all live threads:

BTraceUtils.threadCount()

But how to get the IDs? I want to know which threads are live when a method (@OnMethod) is called.


Solution

  • Since it is not possible to use loops in BTrace scripts an array or list of thread ids wouldn't be of any use.

    You would have to switch to the unsafe mode to enable unsafe features (like eg. loops) and when you are in unsafe mode you can use the standard ThreadMXBean methods to get the thread ids.