can somebody kindly suggest some solution In case I want to get the calling class name of a thread's start method
for example if I start a thread in main the stack trace gives calling class name as thread and caller method name as run for index 2. please help in finding the correct names of the caller class and method name of a thread.
Looks like you're trying to tie up tasks that span multiple threads. About the best you can do if you're starting a thread directly is to give it a name in the constructor, then log the calling class and method name along with the new thread's name. But this won't work if you use an ExecutorService
.
More generally you should investigate using Nested Diagnostic Context to allow you to tie up multi-threaded operations: Logging activities in multithreaded applications
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