How Can We Prevent Busy Waiting in Java ?

There is a simple way to prevent busy-waiting in Java. We can just put the current thread to sleep for given amount of time.

It can be done by calling sleep() method of java.lang.Thread class. We can pass the number of milliseconds to sleep() method as an argument.



You May Interest

What are the Main Benefits of Collections Framework in Java ?

What is a Livelock in Java ?

How Can Be Read Data From a Form in a JSP ?

What is the Difference Between DOM and SAX Parser in Java ?

What is an EnumSet in Java ?