Skip to content

Tag: wait

Java Thread is blocked in join()

I have the following simple code in which I put and take from a Queue represented as an ArrayList. I don’t understand why my thread is blocked in join() method. From main I call as follow: Answer Without running it… The close() method holds lock at the time it calls thread.join() and waits on thre…

How do I make a delay in Java?

I am trying to do something in Java and I need something to wait / delay for an amount of seconds in a while loop. I want to build a step sequencer. How do I make a delay in Java? Answer If you want to pause then use java.util.concurrent.TimeUnit: To sleep for one second or To sleep for a minute.

Java Delay/Wait

How do I delay a while loop to 1 second intervals without slowing down the entire code / computer it’s running on to the one second delay (just the one little loop). Answer