Question #29048

How can I simulate busy waiting in Java threads without using suspend();, wait(); notify(), and notifyAll()?

Expert's answer

You can do it in this way:
thread1:

while(!sharedBoolean) {
//busy wait
}

thread2:

sharedBoolean = true;//will wake up thread1

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS