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

How Will You Delete a Cookie in JSP ?

How Will You Use Other Java Files of Your Application in JSP Code ...

What is the Difference Between a Cookie and a Session Object in J ...

How Can You Make an Object Eligible for Garbage Collection in Jav ...

What is the Reason For Overriding equals Method in Java ?