How To Make Java Wait A Second

One of them is in main method and it s for timer and the other is for other jobs and other threads to work with this is my code.
How to make java wait a second. For this the current thread must own the object s monitor. As this is a loop this presents an inherent problem drift. Let s see using a simple example in the below example we are calculating the sum of first 100 numbers using threads and printing the sum in different thread. If you want to pause then use java util concurrent timeunit.
In this version of getbusyflag we wait for the notification for up to 100 milliseconds. To sleep for a minute. Public synchronized void getbusyflag while trygetbusyflag false wait 100. In java we can use timeunit seconds sleep or thread sleep to delay few seconds.
According to javadocs this can happen when. We need to make sure that we call the wait method only from the synchronized block. Simply put when we call wait this forces the current thread to wait until some other thread invokes notify or notifyall on the same object. I have one class and there are two run methods in it.
We ve executed synchronized instance method for the given object. Like wait we have a method notify and notifyall these methods are called after wait method.