Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ambiguity in Master Exam option

 
Ankit Garg
Sheriff
Posts: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was solving one of the master exams and I came up to this option

wait() method can be called from non-synchronized context...

The master exam says this option is false. But the wait method can be called from non-synchronized context. There will be no compilation error only a run time MonitorStateException.

So in the exam will this be explicitly mentioned like this

calling wait() method from non-synchronized context will compile successfully

OR

calling wait() method from non-synchronized context will result in no runtime exception
 
sannuth kashikar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
you will know that in exam.

about the question

wait() method "cannot" be called from non-synchronized context...

wait() method throws runtime exception IllegalMonitorStateException if the current thread is not the owner of the object's monitor.Runtime exceptions are due to logical errors,you have to go back to the code and work on logic to convince JVM .
So "cannot" would be more appropriate.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic