How to use delay

broken image
broken image

Having knowledge of threads you would be for sure aware about main Thread, the thread in which main function is called. To understand the concept of delay we need to understand about Threads in Java, if you are aware about it you can continue reading otherwise we suggest you learn about threads once before moving ahead.

broken image

Like any other programming language, Java supports delays. In such cases we have to use delay in our code. We are aware that calling certain API like Google Maps API would take at least 5-8 seconds of time for fetching a response. Before we move on further to understand the working of delay in Java, let’s understand some practical scenario in which we would need a delay in execution.Īs soon as the application is loaded and the user logged in, we want to fetch the current location of the user. Let’s discuss about scenario when we want to introduce a delay in execution of a subsequent program.