*
The moose likes Threads and Synchronization and the fly likes Thread.sleep in loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread.sleep in loop" Watch "Thread.sleep in loop" New topic
Author

Thread.sleep in loop

Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

I just began using NetBeans 6.9 and it has new hints available to the programmer. One of my classes is a lowe level thread that sleep every 5 seconds after which it verifies the introduction of any USB memory devices into Windows. NetBeans hints to me that a sleep call with a while loop can be dicey, well not exactly in those words. The class functions correctly and there is no noticeable decline in performance of the program. I don't see any other way around the way I have cided the calss below:

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

You'll have to tell us what the message is, if you want some guesses as to what it means. As far as this code goes, nothing wrong with sleeping inside a loop.


[Jess in Action][AskingGoodQuestions]
 
 
subject: Thread.sleep in loop
 
Similar Threads
Sleep or Yield in a infinite loop
Thread.sleep in loop
While loop never stops
Constant running process
sleep method other than of Threads exist