← Back to Java

wait() vs sleep()

Javajava

The Question

What is the difference between wait() and sleep() in Java?

What a Strong Answer Covers

  • wait() in Object releases lock must be in synchronized block
  • sleep() in Thread does not release lock
  • wait() for inter-thread communication
  • sleep() for time delay
  • both throw InterruptedException

Related Questions

  • JVM vs JRE vs JDK
  • Java Platform Independence
  • How JVM Works
  • Main Features of Java
  • public static void main

Practice This Question

Get AI-graded feedback on your answer with follow-up probes on weak points.

Take the Free Assessment
GrindQuestionsAITechnical interview assessment
TermsPrivacyAbout