How to pause execution for 5 seconds in Scala

2 Answers

0 votes
object PauseExecution {

  def main(args: Array[String]): Unit = {
    println("Execution paused for 5 seconds...") 
    
    Thread.sleep(5000)
    
    println("Resuming execution.")   
  }
}



/*
run:
   
Execution paused for 5 seconds...
Resuming execution.
 
*/

 



answered Apr 30 by avibootz
0 votes
import java.util.concurrent.TimeUnit

object PauseExecution {

  def main(args: Array[String]): Unit = {
    println("Execution paused for 5 seconds...") 

    TimeUnit.SECONDS.sleep(5)
    
    println("Resuming execution.")   
  }
}



/*
run:
   
Execution paused for 5 seconds...
Resuming execution.
 
*/

 



answered Apr 30 by avibootz

Related questions

1 answer 47 views
1 answer 36 views
1 answer 49 views
1 answer 41 views
1 answer 45 views
2 answers 44 views
1 answer 35 views
...