File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Exception in Synchronizd Block Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Exception in Synchronizd Block" Watch "Exception in Synchronizd Block" New topic
Author

Exception in Synchronizd Block

Suhani arora
Greenhorn

Joined: Jul 03, 2005
Posts: 8
Hi All !!
Frnds any body Please tell me When a process is in Synchronized block and Exception genrate which is catch after synchronized block .Will this process releinquish all resource which it has in synchonized block

Example :-
connection con=..;
PreparedStatement pstmt=....
synchronized(this)
{
-----

pstmt.executeUpdate();//SQLException genrate here

}

----
catch(here)
{
}
//will this process unlock the table
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Moving to the Java in General (intermediate) forum.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24081
    
  15

Yes. No matter how the synchronized block is exited (returning, falling off the end, or an exception), the monitor will be released.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Exception in Synchronizd Block
 
Similar Threads
try catch block
Try catch block.
Lock Relinquishing......
Exceptions, throwing in a catch or finally bloack
Thread wait() and notifyall()