Best way to implement a timer
I have a quick question, what is the best method for implementing a timer thread. Say you want to record the amount of elapsed time betwean two actions - for instance .. maybe:
user clicks button - timer starts.
user clicks button - timer stops.
getting system current time stored then deducting it from system current time on the second action is a rather inificient way it seemed to me.. Is there a more efficient and eligant method for going about this?
Thanks in advance, I am ever apprechiative.
What the capabilities of the machine actually are.
Code correctness here would be to have poster direct attention to doing some get-going work on what the capabilities of the machine actually are. I do this all the time, I am stiil not out of the mud on the matter.
There was a day when 65k was a luxury, ram was loaded with a boot loader that began with an 80 colum card with a paticular character in the first colum or so....in that domain, reading the clock would be .... what's a better word for non-tivial, significant?
Obscure tricks to gain a few bits here and there were part and parcel of a coder's skills, 4k would be a common programming space for both machine processor instructions and variable .....
Today, a keychain calculator has processor power a business then may have only wished for, useable equipment gets wasted on 16-bit ( or even 8-bit possibly ) instructions that, at best, are designed intentionally to choke the machine down so that it is necessary to download and download ad infinitum, the capabilities of the machine are in general beyond the grasp of those who use the machine. I had an old-timer tell me that the data channel of one high school shop grade optical device is beyond human grasp.
Reading the clock, i dunno one assembler op? No more that ten or twenty at most - which at even a 3-mhz trainer board is vanishingly small. Todays gigabit rates, with terabit either on the board or actually in production, especially combined with 64 to 80 or whatever it is processors already running on one mount on a bench in the shop,...whether poster wants to do Numeric.getValue() or long time = System.readClock() would be either a personal choice or that of posters instructor or employer.
Getting in scope what the capabilites of the machine are would be Code Correctness here.