This question is much a standard C Linux coding question, but the natural solution would be the next one..
If you have the control of the code you run, you should know where is the entry point of your thread after its start, and where it will finish before its destruction.
Just setting up a timer that start at the beginning and stop before the end of the thread should be OK for the information you ask.
Kind regards,
Erwan.
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.