Can you print out what line in the code and what method a running thread is in, from within a program - without using some monitoring software like visualvm? Do you have to extend Thread?
If this is just for quick-and-dirty debugging or error reporting, you can just do
new Exception().printStackTrace()
If you want to be a little fancier than that, you can use Thread.currentThread().getStackTrace()
to get an array of StackTraceElement
objects; you can determine the current line number by examining those.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With