Simple question - how can I measure time?

Hi everyone.
I'm implementing an algorithm in Java and I need it to run for approximately 1 minute... is there anyway to run a for loop (or similar) for a specific measure of time? Has it got anything to do with checking the system clock?
Many thanks!

It all depends on the situation... If you want your code to stop exactly at 1 minute, regardless of what it's doing, you have to have to kill the thread from some outside source, so a Timer would be better there. If you just want your loop to just do something repeatedly for about a minute, then checking the time in the loop should be sufficient. Presumably you want the code to finish at least a complete iteration or have checks in between lines of code to stop at proper places to avoid strange state issues (again, depends on what the code is doing).
I agree, that using Timers with a flag is probably a more sound solution, but the timer is a thread which sleeps, so there could be just as much delay in that timer firing as the code in the loop takes to finish before the next time comparison. There's no absolute guarantees on the timer's timing. From the java.util.Timer API docs:
This class does not offer real-time guarantees: it schedules tasks using the Object.wait(long) method.

Similar Messages

  • How can I measure time between transitions at digital input

    I am using LabVIEW 6.0 to measure the time duration between 2 transitions in a digital input port. I have a set up including an HP 34970A Data Acquisition unit with the 34907A Multifunction Module plug-in. The LabVIEW program is trying to poll the digital input for level changes and then using the Time function(Tick Count) to check the times at the transitions. However this method doesn't work reliably as I have to measure time periods of 500ms.
    Is there any good way of mesuring time period with the above setup. I don't have a module which connects to the internal multimeter in the 34970A. The other stuff I have are a HP 34903A(Actuator Module) and a HP 33120A(Function/Waveform Generator).
    Any method for m
    ore accurate time measurement with the above setup will be appreciated. If not, what else do I need to make accurate time measurements.

    Frankly I doubt that you're going to be able to measure time interval with much accuracy. You're periidically polling a static digital input and how often you poll is going to vary. You could try polling as fast as possible and eliminate as many background tasks as you can. If your tolerance for the measurement is plus or minus 100 msce, then maybe you'll get a decent measurement most of the time. If it's plus or minus 5/10 msec, then it will never happen. The pc's clock is just not that accurate and a software timed loop on Windows is not deterministic enough. Get a counter/timer board for something really accurate or use a scope to capture the waveform.

  • How can you build time series measures in OBIEE without using TODATE AGO fu

    How can you build time series measures in OBIEE without using TODATE and AGO function?
    Please provide steps to build time series
    measures in OBIEE without using TODATE and
    AGO function. Dashboard results not storing
    in cache when using TODATE and AGO functions.
    eventhough its cached users queries not
    hitting cache because queries doesn't match
    exact date time when using TODATE and AGO
    functions. so I want to build queries using
    sysdate and some simple calculations. Please
    send your inputs/ideas for my questions..
    Thanks in Advance

    This can be using Msum function in answers. Use the following formula, here dollars is my metric. Change the formula based on your metric.
    Msum("Sales Measures".Dollars ,2) - "Sales Measures".Dollars
    the report will be cached and better performed compared with time series. check ti
    - Madan Thota

  • HT5699 I was trying to buy a movie in itunes for the first time but I don´t remember my answers to apple´s security questions . how can I do? thank you very much

    I was trying to buy a movie in itunes for the first time but I don´t remember my answers to apple´s security questions . how can I do? thank you very much

    Hey antonio.b5,
    Thanks for using Apple Support Communities.
    If you can't recall your Apple ID security questions and answers, the optional rescue email provides a way to reset them.
    Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/ht5312
    Have a nice day,
    Mario

  • How can I count time with labview7?

    Hi
    How can I count time with labview 7 and NI-DAQmx like I did with labview 6.1 and "count time-easy.vi" (count event or Time.vi).
    I have a 6025E and labview 7.0
    Thanks

    I am not sure what you want to do or why..
    ... but here goes (some suggestions)
    If you want to count the time between two events, you have a choice, you may use the Tick Count. Inisitalize it first by getting a timestamp and then do a difference within a loop. The difference will give you the time elapsed in ms.
    You can also use the Get Date/Time String or Get Date / Time in seconds and once again take a snapshot when a first even occurs and another snapshot at the next even (at a point where you want to measure elasped time). This method is particularly useful if you want to timestamp an event.
    If I didn't answer your question, can you elaborate what you mean by "How can I count time".
    Best of luck..
    JLV

  • New comer ask 2 simple questions:how to set the use of the right click of

    New comer ask 2 simple questions:how to set the use of the right click of your mouse?
    I don't know why when i click the right button of my mouse in logic, sometimes it's the same funcion as my left one, some times it's the same function that opens the tool menu....But in MacOSX,it's all okay.Just the weired thing in logic ,please help
    2.is there any kind of filter in Score? I mean, in midi track I have a C1 note, and I don't want the C1 note shown in my score, I want every note show which are above C2, like a filter. I think this is helpful dealling with some keyswich things,how can we do that?

    In Preferences -> Global -> Editing you can choose weather right click is assignable or opens the tools box.
    Not to sure about the score dude

  • Really?  All Adobe has for customer service is a forum?  I have a simple question.  Can't just contact someone?  Are you that cheap?

    really?  All Adobe has for customer service is a forum?  I have a simple question.  Can't just contact someone?  Are you that cheap?

    Not to be critical, but in the time you have waited to find out how to contact Adobe you probably would have had your question answered by someone here on the forum. Many times people have been given bad information when they have found a way to contact Adobe. Much of the so-called technical support has been outsourced overseas. And the people manning the phones have no experience with Adobe products. So you can complain some more. Or, you can ask your question. It's your choice.

  • HT5787 If i know email ( but i dont have acces to it ) and i dont have secret questions how can i recover my icloud account ?

    If i know email ( but i dont have acces to it ) and i dont have secret questions how can i recover my icloud account ?
    I'n my company ( pawn shop ) i hope i transleted fine , i bought an iphone wich it seems to be ok at the first time.
    That was on 26.11.2013 ( as can be seen in my pawn contract and billing ) . after 2 weeks i found a client to buy my second hand iphone and the i saw my mistake it is icloud blocked i need that password so i can reset the iphone to sell it. how can i manage this problem ? i can provide all my billings, contracts, society data everything.

    If you know the primary email linked to the account but do not have access to it or the answers to the security questions, then the next best thing to do is call Apple at 800-275-2273 and ask for Account Security.  They will ask you for two pieces of information from the account in order to unlock it.  The options are usually the security questions (each question counts as one piece), the credit card linked to the account, and either a device serial number or device verification code that they will send you.
    After this verification is complete they can send the reset link for your password to any email you choose.  Please be aware that if they verify you with something other than two security questions, there is a 24 hour wait before the email arrives.
    Good luck!

  • HT4753 I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    It's actually even easier than using Save As to see the full path to the currently open document. Just do a "Secondary click" on the document title in its window's title bar.
    Like you, I relied upon Save As my whole life to check a file's location and considered it a must-have capability. Turns out it's even faster to use the single-click method to reveal the full path to the open document. It displays the entire path to the current document starting from the level of your Mac, and works for files stored on drives as well as iCloud.
    If you're not sure how to do a secondary click, go into System Preferences, select Trackpad, Point & Click to find the current preference for secondary click on your Mac. If you happen to have a mouse with more than one button, it's probably the right button. As a trackpad user, I check the box to "Click or tap with two fingers," so a simple two finger tap on the title of an open document reveals its full path. This feature actually has been around for a very long time.
    Note that this is not the same thing as the Autosave and Versions menu, which is exposed using a little drop down triangle to the right of the title. There is no visual clue for the presence of this feature - you just have to know it's there, probably because this feature goes all the way back to pre-OS X days.

  • How can i use time machine with a network drive

    I have a Western Digital Net N900 wireless router with a 2TB internal H/D. How can I get Time Machine to reconize it?

    Relying only on TM to me is iffy but I would bet you have clones in addition to TM like I do.  I agree with everything you said but to the OP question, it is possible.  A time capsule or AEBS+HD are pretty similar but one is officially supported while the later is not.
    Since I'm rambling a bit I will add this.  I only use TM for the times I delete something and then wish I had it back.  All my restores or migrations are done from my clones.  One clone is made weekly and is a snap shot of my system.  One clone I keep remotely located and is updated monthly.
    My system:
    Internal 1TB
    Ext HD1 2TB (1TB data, 1TB clone)
    Ext HD2 2TB time machine backup (internal + HD1 data, not the clone)
    Remote 1TB clone
    I'm fully redudant with my method and it has saved me before.

  • Simple question. Can i use the iPad charger in my iPod touch?

    Simple question. Can i use the iPad charger in my iPod touch?

    Yes. I use mine all the time.

  • HT201250 How can i use Time Capsule as External Drive

    Hey Guys,
         I just have query about time capsual , How can i use time capsule as my external drive as i have 2TB with me i can take the Backup as well i can put all my pic and music in time Machine if i can use as External HD ! Can some one Please help me in this will be highly appreceate.
    Thanks
    Monal Thakkar
    Amrapali Group

    You need to get an external HD for the "overflow" of stuff that won't fit on your Mac.
    Format it for a Mac (see #1 in Using Disk Utility), even if it says it's compatible.
    Then copy what you want to the external HD.  Most things you can just drag and drop; but for iTunes and iPhotos see: Moving your iTunes Music folder and Moving your iPhoto '11 Library.
    Then let your Time Capsule back up both your Mac and the external HD.  See Time Machine - Frequently Asked Question #32 for info and details.

  • How can I store time machine backups on Amazon Glacier?

    Hello,
    How can I use time machine to backup my mac and have the time machine files stored on Amazone Glacier? upload is easy but I wonder how to restore a backup on Glacier to the mac.
    Thanks.

    You need to create the sparsebundle on external drive.. then copy it to the cloud store area. You cannot directly backup TM to the cloud.
    And please note.. sparsebundle is a single file.. if a small file inside it corrupts.. the whole thing is corrupt. It might be repaired perhaps but any failure is far more serious than a failure in a simple backup.
    I still think TM is unsuitable. You are far better using a software that can rsync to backup.. ie CCC.

  • I am unable to remeber my answers to my security questions how can I get this changed

    I am unable to remeber the answers to my security questions how can I change these questions?

    No offense, but this question is asked five times a day.  Just do a Google search on it or click a link under "More Like This" to the right of this page, and you'll find your answer.

  • I have two editors working on FCPX in two different cities. Here is the question: How can a project timeline be shared if they are working from mirrored source files?

    I have two editors working on FCPX in two different cities. Here is the question: How can a project timeline be shared if they are working from mirrored source files? Is there any easy way to share a project time line?

    There an episode of MacBreak Studio where Steve Martin explains exactly how to share a project, while having two separate copies of footage and events:
    http://www.youtube.com/watch?v=Hu-ga7fxKh8

Maybe you are looking for

  • How to print Page No. in ALV footer.

    I am using the follwoing code but when I got print the page numbers are not displaying. I was copy the code from one of group message. Please tell where I am making mistakes means why page numbers are not displaying at footer. I want to print 30 rows

  • Bad bind variable 'NEW.SYS_NC_ROWINFO$

    Hi in order to assist in error resolution when inserting XML data into a XMLTYPE table I have attempted to create a trigger on the table as SQL> CREATE or replace TRIGGER VALIDATE_PersonAlert3 2 before insert on pa_tab3 3 for each row 4 declare 5 XML

  • A statement is not refreshed as if Statement Caching was enabled

    Here is the c# code: OracleConnection conn = null; OracleCommand cmd; OracleDataReader reader = null; string tname; conn = new OracleConnection("Data Source=ora10gen;User ID=scott;Password=tiger;"); conn.Open(); cmd = conn.CreateCommand(); cmd.Comman

  • Document Management App that runs on OS X Server?

    I need a CMS or EDMS application (for document management) that runs on the mini-mac server.  Others will access via browser. Thin-client application. Similar to DocuWare or OnBase or IBM Content Manager, but APPLE FRIENDLY!!!!! Many thanks - [email 

  • How to transfer inventory goods to asset

    Hi, Certain items of capital goods have been posted to inventory at time of goods receipt. The same have to be transferred to asset code. How can I transfer these inventory goods into asset in the system? Rgds, GAG