Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calculating the thread run time  RSS feed

 
ARS Kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a program which creates multiple threads to do the same thing. The idea is to simulate the concurrent usage of the resources of a specific application. So in this program I would like to display the timings for each thread after all threads are completed. Now I am invoking the threads from the main program and inside the run() method calculate the time before and after the method which does the work.
I did write a finally part to the run() method and it is printing me what I am looking for. I am just confused about why the finally part is working only once even if I have 100 threads running at the same time.
Also as I am not sure this is the only way to achieve what I want, please suggest some better methods if any.
Thanks in advance
-ARSKumar.
 
ARS Kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Now I know that each finally is getting its time to run . So how will I get all these data ( the time to run each thread ) in the main thread ( the main method ) ? I would like to display a average response time inside the main method.
-Regards
ARSKumar.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!