• Post Reply Bookmark Topic Watch Topic
  • New Topic

synchronized method.  RSS feed

 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a synchronized method throws an exception in it's execution, the lock accquired by it is released automatically ? Is this true or false;
I think it's false. Am i wrong ? I think that the object will not release the lock if the error occured or does it ?Please explain your answer.
 
sreek, Thiru
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i may not be able to give u a solid answer but... as far as i know when ever a thread looses its control it frees all the locks held by it.so i guess it depends on ur exception handling
--sreek
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks , yes i just read explanation someplace it says that the threading mechanis releases the lock held on the object when an exceptions occurs automatically. Again thanks.
 
kiran babu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friend,
As soon the synchronised method throws exception the lock will be released because if it is not released no other threads can access the method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!