File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Can synchronized( someObj ) ever throw an exception? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can synchronized( someObj ) ever throw an exception?" Watch "Can synchronized( someObj ) ever throw an exception?" New topic
Author

Can synchronized( someObj ) ever throw an exception?

Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
I know that object.wait() can throw an exception (IllegalMonitorStateException or InterruptedException) can synchronized ever do the same?

For example:



What is that synchronized line in byte code?
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

If you try to synchronize on a null reference, a NullPointerException will be thrown. (See JLS - 14.19.)


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can synchronized( someObj ) ever throw an exception?