Andrei Botalov
Andrei Botalov

Reputation: 21096

How to listen for current thread changes?

I want to know in every moment of program execution what thread is executed now (not all threads in JVM but only threads that belong to my program).

How can I get it?

Upvotes: 1

Views: 186

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533492

YourKit can show you which threads were running, blocked, waiting etc at any given moment and give you a snapshot of the stack at intervals.

You can create a process to poll all the threads yourself with Thread.getAllStackTraces() which gives you the stack trace of every thread. Using a GUI tool is much, much easier.

Upvotes: 1

Related Questions