Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

Question for java guru

 
Richard Walter
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Report post to moderator
HOping someone could tell if execution i catch statement blocks remain synchronised, as in the following code?
synchronise (object) {
try {

//do something

} catch (Exception1 e1) {
//do soemthing here
//is it still synchronised

} catch (Exception1 e1) {
//do soemthing here
//is it still synchronised

}
}

Would be gratefull if you could also point me to an official source that clarifies this. Also, are ther any general issues, best practices etc.. to conisder in the above code example??
Thanks,
Richard Walter
 
Maciej Kolodziej
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
Everything inside synchronized block is synchronized and so are the catch statements.
 
Maciej Kolodziej
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Report post to moderator
And oh, You wanted some source. I recommend Thinking in Java second edition. Synchronization is described in chapter 14.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am closing this discussion. Please refer to this duplicate thread for answers and continued conversation.
[ February 15, 2002: Message edited by: Ajith Kallambella ]
 
    Bookmark Topic Watch Topic
  • New Topic