How to wait for N seconds between statements in Scala?

Mamun picture Mamun · Feb 20, 2016 · Viewed 57k times · Source

I have two statements like this:

val a = 1
val b = 2

In between the 2 statements, I want to pause for N seconds like I can in bash with sleep command.

Answer

Carson Pun picture Carson Pun · Feb 20, 2016

You can try:

val a = 1 
Thread.sleep(1000) // wait for 1000 millisecond
val b = 2

You can change 1000 to other values to accommodate to your needs.