0

I found three cases when a lock on a resource is released:

1) wait() method;
2) get an exception;
3) thread complete its execution

Are there other cases?

Cœur
  • 34,719
  • 24
  • 185
  • 251
DistribuzioneGaussiana
  • 1,879
  • 5
  • 24
  • 49
  • Uhm, *who* release the lock then? From what source were those cases determined? And what is *really* meant by 'lock is released'? For instance `synchronized (x) { /* lock will not be released until this block exits */ }` runs counter to the stated cases. – user2864740 Jul 02 '15 at 23:28
  • For example, if I have something like this: `synchronized void method() { while(condition) wait() ...... doAction; notifyAll(); }` If the while condition is right my thread releases its lock. I want to know, in general, if there are other cases. – DistribuzioneGaussiana Jul 02 '15 at 23:34
  • Might be useful reading - http://stackoverflow.com/questions/13249835/java-does-wait-release-lock-from-synchronized-block – user2864740 Jul 03 '15 at 00:20

0 Answers0