aspose file tools
The moose likes Threads and Synchronization and the fly likes Program running time Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Program running time" Watch "Program running time" New topic
Author

Program running time

Jack Rudolf
Greenhorn

Joined: Sep 05, 2004
Posts: 13
Heyy..
Could you help me how to make a time for running program?
It should start timing the moment we open the program until when we close it. It works like the timer in the mobile phone.
The value will be displayed in the JTextArea.
btw, Can we actually send the time to JLabel?

Thanks guys!!
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Shall it work with different programs, or just with one?

If it works for just one program, it could be a part of the program, but of course couldn't exactly measure from before starting - end of program.
You could display the result in a dialog or frame, which has to be closed, after the rest of the program has finished and stopped the timer.

Another way would be to communicate over sockets, but in this case too, the program started running before sending the message.

Is exactness of milliseconds important?

The last question:
(untestet)
[ September 06, 2004: Message edited by: Stefan Wagner ]

http://home.arcor.de/hirnstrom/bewerbung
Jack Rudolf
Greenhorn

Joined: Sep 05, 2004
Posts: 13
Shall it work with different programs, or just with one?
No, it just works on one program only...the exactness of the miliseconds is not important. it just need to be exact to seconds only.!! thanks!
Kedar Bhawarthi
Greenhorn

Joined: Jun 21, 2004
Posts: 10
let me know if this trick helps you...

it will check approximate milliseconds spend for loop.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Or you could use the Jakarta Commons Lang StopWatch...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jack Rudolf
Greenhorn

Joined: Sep 05, 2004
Posts: 13
Kedar, your method is working. but it does not reset and start from 0 at the starting of the program. It should start from 0 again after u have close the program.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Program running time
 
Similar Threads
Can I have a trigger in Java?
Getting an input from the user using command-line arguments?
extending from Exception
Lock Table issue: Need help
Threads