File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply locked New topic

Thread.sleep in loop

Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 191

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:

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63552

Please take care to post a question just once. Thanks.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Thread.sleep in loop
jQuery in Action, 3rd edition