Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads wait() question

 
Janki Shah
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why at line #1 it prints 99999? shouldn't it wait() forever? Because there is no notify().
 
Henry Wong
author
Marshal
Pie
Posts: 21385
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Janki Shah wrote:
Why at line #1 it prints 99999? shouldn't it wait() forever? Because there is no notify().



This question, or question related to the same issue actually comes up often....

http://www.coderanch.com/t/565836/java-programmer-SCJP/certification/Misunderstanding-wait-method
http://www.coderanch.com/t/546560/java-programmer-SCJP/certification/Notify-notifyAll
http://www.coderanch.com/t/490052/java-programmer-SCJP/certification/wait-notify-test
http://www.coderanch.com/t/489800/java-programmer-SCJP/certification/Confusing-wait-notify
http://www.coderanch.com/t/487066/threads/java/wait-notify-notifyAll

Henry
 
Janki Shah
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Henry.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic