Make a Thread to get sleep for a time that has decimals

I need a Thread to get sleep for a time that has decimals, for example 3,5 miliseconds but is not possible because the Thread.sleep() admits only long. Is not other way to do it?
Thanks

dannyyates wrote:
Well, there's sleep(long millis, int nanos), but to be honest if you're requirements are that tight, sleep() is probably not the right tool for you because if doesn't really guarantee any level of accuracy.That's true, the accuracy of sleep() depends rather on the underlying OS and hardware. As the docs say:
"Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, *subject to the precision and accuracy of system timers and schedulers*. "
Just run this simple test program, it gives interesting results:
     long start, stop;
     for (int i=0; i<100; i++) {
          start = System.nanoTime();
          try {
               Thread.sleep(5);
          } catch (InterruptedException e) {
               e.printStackTrace();
          stop = System.nanoTime();
          System.out.println("The thread slept for " + (stop-start)/1000000.0 + " ms");               
     }On my Windows XP with dual core CPU I get:
The thread slept for 5.801576 ms
The thread slept for 5.778108 ms
The thread slept for 6.134019 ms
The thread slept for 5.437562 ms
The thread slept for 6.064458 ms
The thread slept for 5.674744 ms
The thread slept for 15.354466 ms
The thread slept for 5.869461 ms
The thread slept for 5.785372 ms
The thread slept for 5.804649 ms
If you really need a precise timer you need either a real-time OS or a different solution, the method sleep(millis, nanos) will solve the problem without proper OS/hardware

Similar Messages

  • HT2534 How does one get reimbursed for an app that has been immediately deleted after download and open?

    I downloaded an app that cost $7.99 and immediately realized that it was not functional the way I understood it to be. I deleted the app and now I wqould like to be reimbursed.
    How does one go about getting that accomplished?
    Thanks - George

    Dear telwow,
    Apple did not do anything to solve this problem, they said I shoud apply to ITunes which I did. However, ITunes in Belgium does not even have a customer friendly call center, and they reply with standard info if you apply by e-mail which have no relevance to my problem. As I do not have hours to spend on the phone, I tasked my secretary to call Itunes many times. In the end, she found someone to look into the matter which took months.
    Simultaneously, I applied to VISA through my bank for fraud investigation. I had to cancel my credit card. In the end, VISA paid my money back and they said they will deal with ITunes. I received a new credit crad from VISA with a new number. I tried to use this new card in the ITunes but ITunes did not accept my card because in their system my name has been registered as if I have commited the fraud! This was again outrageus! I have complained about this to both Belgium and the USA Apple/ITunes, but no satisfactory answer was given. I am now using my wife's credit card to buy smth I want in ITunes. But because of my very unpleasant experience I am not buying much on ITunes store. I am also considering to quit Apple all together. This is unfortunate because I have been an apple fan until I had this experience.
    Many thanks for sharing your problem.
    Mustafa

  • I am getting a message. What does it means "We're sorry, but this is a serial number for a product that has been replaced. Please check your information and re-enter your serial number. "

    I have tried getting service support information from Apple Support Service. When entered my serial no. got this
    I am getting a message."We're sorry, but this is a serial number for a product that has been replaced. Please check your information and re-enter your serial number. "
    What does it means???

    ashishtgb wrote:
    I dont have any idea . I brought out it new from the market.!
    Well, when you purchase from a non-official source you run the risk of getting who knows what from wherever. It appears this phone was replaced under warranty at some point, but not returned to Apple for refurbishment. Thus, the SN is no longer valid for warranty & service. If you can return it and get your money back, I'd suggest you do so.

  • How to get Reports for specific User that how many password has been reset using FIM SSPR in FIM 2010 R2 SSPR

    Hi,
    How to get Reports for specific User that how many password has been reset using FIM SSPR in FIM 2010 R2 SSPR
    Regards
    Anil Kumar

    Hello there Anil,
    A simple way to quickly get a overview is to look at the request history within the portal environment (note that this will expire in a few day based on your environment, after that you would need to FIM Reporting Module - but you could increase this to
    maybe 60 days to so, watch the DB size).
    To do this you could create some custom search scopes of do some custom queries. The creator of the SSPR activities always has the same GUID so you can use that so search.
    In your search scope you can use the following XPath to play with.
    - All Password Reset Requests - /Request[Creator='b0b36673-d43b-4cfa-a7a2-aff14fd90522' and Operation='Put']
    - All Completed Password Reset Requests - /Request[Creator='b0b36673-d43b-4cfa-a7a2-aff14fd90522' and RequestStatus=‘Completed']
    You can play with the "RequestStatus".
    Hope this helps.
    Almero Steyn (http://www.puttyq.com) [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or "Helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer
    faster.]

  • Concurrent timers are not getting invoked for same timer inf

    Do weblogic has some parameter in weblogic deployment descriptor like numAlarmThreads="5" minThreads="1" maxThreads="10" etc
    becoz I am facing one problem relating to timer service in EJB
    Problem Scope: Concurrent timers are not getting invoked for same timer info (Serializable object containing the details of timer).
    Details : I am implementing EJB timer 2.1 and when ejbTimeOut execution of one timer exceeds the interval time, next timeout doesn’t happens till the execution of first ejbTimeOut completes . Ideally the timers should behave in the manner that on every interval the ejbTimeOut should occur no matter the previous timeout is completed or not
    for example : consider there is timer T whose timeout occurs every minute, and on every timeout it calls process P, so on every minute ideally container should give call to process P irrespective of the previous status of P (call is complete or not). In our case next call to process P is not happening after timeout also since it is waiting for previous call to P to get completed

    You should also cross-post this in the WebLogic EJB forum:
    WebLogic Server - EJB

  • Concurrent timers are not getting invoked for same timer info (Serializable

    Problem Scope: Concurrent timers are not getting invoked for same timer info (Serializable object containing the details of timer).
    Details : I am implementing EJB timer 2.1 and when ejbTimeOut execution of one timer exceeds the interval time, next timeout doesn’t happens till the execution of first ejbTimeOut completes . Ideally the timers should behave in the manner that on every interval the ejbTimeOut should occur no matter the previous timeout is completed or not
    for example : consider there is timer T whose timeout occurs every minute, and on every timeout it calls process P, so on every minute ideally container should give call to process P irrespective of the previous status of P (call is complete or not). In our case next call to process P is not happening after timeout also since it is waiting for previous call to P to get completed

    You should also cross-post this in the WebLogic EJB forum:
    WebLogic Server - EJB

  • Concurrent timers are not getting invoked for same timer info

    Problem Scope: Concurrent timers are not getting invoked for same timer info (Serializable object containing the details of timer).
    Details : I am implementing EJB timer 2.1 and when ejbTimeOut execution of one timer exceeds the interval time, next timeout doesn’t happens till the execution of first ejbTimeOut completes . Ideally the timers should behave in the manner that on every interval the ejbTimeOut should occur no matter the previous timeout is completed or not
    for example : consider there is timer T whose timeout occurs every minute, and on every timeout it calls process P, so on every minute ideally container should give call to process P irrespective of the previous status of P (call is complete or not). In our case next call to process P is not happening after timeout also since it is waiting for previous call to P to get completed

    You should also cross-post this in the WebLogic EJB forum:
    WebLogic Server - EJB

  • How do i get refunded for the apps that no longer work due to the fact i cant upgrade my phone?

    how do i get refunded for the apps that i purchased that no longer work due to the fact i cant upgrade my 3.1.3 iphone

    I have never bought an app but on all other things Apple  somewhere has in tiny print the system requirements for running the software.  If you're going to live in the world of outdated technology the way I do, you will quickly learn to always read system requirements.
    iTunes Customer Service Contact - http://www.apple.com/support/itunes/contact.html - Apple states all sales are final, but you can always try.

  • How do I get Firefox to prompt me to remember a password for a site that has already been visited?

    How do I get Firefox to prompt me to remember a site password for a site that has already been visited (probably in private mode)?

    Remove site(s) from the Exceptions:
    * Firefox > Preferences > Security: Passwords: Exceptions
    *http://kb.mozillazine.org/Password_Manager
    *http://kb.mozillazine.org/User_name_and_password_not_remembered
    *Saved Password Editor: https://addons.mozilla.org/firefox/addon/saved-password-editor/

  • How do i get refunded for a video that i didn't want or wrongfully and that isn't downloaded yet?

    how do i get refunded for a video that i didn't want and which hasn't been downloaded yet?

    You don't.
    There are no refunds.
    Sorry.
    You can try contacting itunes support and asking for an exception, but they are under no obligation to allow.

  • Loking for a Doc that has the definition of the calculations that used in Historical reports.What makes up Average Queue time?

    Looking for a Doc that has the definition of the calculations that are used in Historical reports.
    What metrics are used in Average Queue time?
    What metrics are used in Average Speed of answer?

    If you're on UCCE, the Reporting Guide and the Database Schema are fantastic resources.
    http://www.cisco.com/c/en/us/support/customer-collaboration/unified-contact-center-enterprise/products-user-guide-list.html
    http://www.cisco.com/c/en/us/support/customer-collaboration/unified-contact-center-enterprise/products-technical-reference-list.html
    -Jameson

  • Does anyone know of an e-reader app for the iphone that has text to speech capability? I have a Kindle 3G that can read whole pdf documents and books but I cannot figure out how to do it on my iphone 4.

    Does anyone know of an e-reader app for the iphone that has text to speech capability? I have a Kindle 3G that can read whole pdf documents and books but I cannot figure out how to do it on my iphone 4.
    All of the apps I have found on the App store either do not have the text to speech capability or if they have it they will only read a page at a time or simply read the text you paste into their window. I really do not understand what is so difficult about having this feature as Kindle provides it--though Amazon does not make the feature available on its iPhone 4 app.
    Please help.

    thanks. yes i am aware of the VoiceOver feature but it is NOT the solution to my problem. as you said, it is a solution to a different set of issues. i want the text to speech ability because i there are books i need to read but do not have the time to sit down and read them and have become used to listening to them read to me either by a professional human reader or with the text to speech software on the Kindle.
    I think Apple makes the best audio devices but i am really disappointed in this inexplainable shortcoming. if apple can give us siri they ought to be able to design a nice little button that i can push to turn on text to speech while i am in a document, book, magazine or webpage. clearly it is possible as apple has added the "reader" button in safari to have web pages dropped into the reader format.
    thanks for your suggestion though, it is what everyone suggests but it does not address the issue.

  • When entering my phone serial number it shows "We're sorry, but this is a serial number for a product that has been replaced. Please check your information and re-enter your serial number. If your information is correct, you may need to contact us."

    Hi,
    I had purchased an iPhone 5 last month and got the OS updated to iOS 7, yesterday.
    The data cable was of very bad quality and when I took it to the retailer for replacement, they said that its not covered under the one year warranty.
    Secondly, I have also been experiencing network coverage issues with this phone. So, I decided to contact apple care through the web. When entering my serial number/IMEI it says, "We're sorry, but this is a serial number for a product that has been replaced. Please check your information and re-enter your serial number. If your information is correct, you may need to contact us."
    Does anybody have any idea what the reason behind this could be.
    - First time with iPhone and frustrated.
    Briju

    If you purchased the iPhone from Apple or an authorized Apple reseller,
    contact them for assistance. If you purchased elsewhere, go back
    to that retailer and get them to give you a new iPhone or your money
    back.
    If you have checked the serial number carefully and re-entered it
    and that gave you the same error message, contact Apple if purchased
    from Apple or authorized retailer; otherwise you have been scammed
    and need to pursue the matter with the business you obtained the
    iPhone from.

  • We're sorry, but this is a serial number for a product that has been replaced. Please check your information and re-enter your serial number. If your information is correct, you may need to contact us.

    i am going to buy iphone 5 32 gb from some before i bought i check the serial number of that iphone on apple web site to cross check but massage is appering that ......'
    We're sorry, but this is a serial number for a product that has been replaced. Please check your information and re-enter your serial number. If your information is correct, you may need to contact us....
    can any one tell me what is that mean..... replace what ?

    In most cases, what you said is true...however, this is not always the case.  Take myself for example...
    1: I posted my phone online to sell
    2: Someone saw my serial number and called AppleCare to get a replacement phone
    3: An inferior AppleCare representative bypassed a component validation (check serial number to the device on hand) and approved the replacement under my AppleCare plan.
    4:  After noticing this (about 4 days after it happened) and  a trip to Apple and a call to AppleCare, all was resolved.  My phone is back to being covered under AppleCare+
    5:  I learned my lesson.
    So, as you can see, there is a chance that it can be something else.  Although, if the person selling the phone notices, it shouldn't take long to resolve it. Chances are that it is what you said.
    Hope this helps

  • We're sorry, but this is a serial number for a product that has been replaced

    Today i bought one iphone 5 but when i check the serial number in self support not exist my serial no is DNPJGFSDDTTR message showing is
    We're sorry, but this is a serial number for a product that has been replaced. Please check your information and re-enter your serial number. If your information is correct, you may need to contact us.
    Finding your serial number is easy. See how.
    pls help us... to resolve the issue.

    You are not speaking to Apple. This is a user forum.
    If it's possible, return the phone and get your money back.
    You bought a gray market phone that was reported lost or stolen or was already replaced by Apple and was re-sold illegally.
    It has no warranty.

Maybe you are looking for

  • How to get League of Legends working in Arch!

    I didn't like the old wiki guide which required a chroot to run the game from wine, so I rewrote it: wiki guide. An alternative method (mentioned in the guide) is patching Wine instead of the textures of the game, but I hear that can break compatibil

  • I have a problem when I am using the SIRI

    Hello I have an iphone when I am using the SIRI and want to call a contact with the # 995*******, you can not make the call. The ISP provider is movistar. <Edited By Host>

  • Two Alerts for one scenario: Application Error and No mapping found

    Hello, we have a synchronous scenario here embedded in an BPM. The last send step step is sync. The receiver is a web service (SOAP adapter) which sends back a response. Problem with the response from the service: First test: error entries in SXMB_MO

  • Why does Firefox sometimes open a new window when I navigate to an existing tab?

    I often have 7 or 8 tabs open in Firefox. Sometimes when I click on a tab, Firefox opens it in a new window instead of just going to that tab. I haven't figured out a pattern when it does this.

  • Third Party and Sales Deal Combination

    A Client has a business process where the vendor normally delivers goods to the client and the client sends it to the customer with some secial promotional pricing. But at times the vendor is not able to deliver the goods on time to the client so the