Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Calculating the thread run time

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic