Results 1 to 5 of 5

Thread: Exactly

  1. #1
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default Exactly

    How can I restart a thread EXACTLY every 0.5 seconds or quicker?
    Last edited by PhQ; 09-17-2010 at 08:44 PM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,272
    Rep Power
    25

    Default

    Not sure how/if its possible to restart a Thread that is currently running. And if it has stopped running by exiting, I don't know if you can use it again. If the Thread calls wait() before the .5 second limit, then you could use notify() to restart the thread. The notify could be called using a Timer.

  3. #3
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default

    Quote Originally Posted by Norm View Post
    Not sure how/if its possible to restart a Thread that is currently running. And if it has stopped running by exiting, I don't know if you can use it again. If the Thread calls wait() before the .5 second limit, then you could use notify() to restart the thread. The notify could be called using a Timer.
    But it will take like 0.1 seconds to execute the method, is it going to effect the timer?

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,272
    Rep Power
    25

    Default

    is it going to
    Write a test program and see what happens.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Quote Originally Posted by PhQ View Post
    How can I restart a thread EXACTLY every 0.5 seconds or quicker?
    You can't. The best you can do is run a Timer with a firing interval somethng less than 0.5 seconds -- maybe 0.4 seconds -- and hope it will never exceed 0.5 seconds.

    Why do you have such an odd requirement in the first place? The context may suggest a better solution.

    db

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •