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 Stack and Heap Work in Java Multi-threading Environment ?

What are the Differences Between Comparable and Comparator in Jav ...

How Can We Improve the Performance of IdentityHashMap in Java ?

What are the Thread-safe Classes in Java Collections Framework ?

What is the Use of a Dictionary Class in Java ?