You are developing a real-time gaming application where certain operations need to be repeated at regular time intervals. Which looping mechanism and timing control statements would you use to achieve this without blocking the user interface?

  • do-while loop and Thread.yield()
  • for loop and System.nanoTime()
  • forEach loop and System.currentTimeMillis()
  • while loop and Thread.sleep()
In a real-time gaming application, you would typically use a while loop in combination with the Thread.sleep() method to introduce a delay between iterations without blocking the UI. The other options may not be suitable for achieving this specific timing control.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *