aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 24166
    
  30

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]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Thread.sleep in loop
 
Similar Threads
Thread.sleep in loop
Constant running process
While loop never stops
sleep method other than of Threads exist
Sleep or Yield in a infinite loop