aspose 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Can synchronized( someObj ) ever throw an exception?
 
Similar Threads
Interrupt, Interrupted and isInterrupted
wait() not syncronized on this but not throwing illegalMonitorStateException
44/80.....damn locking!
Using MySql with a Java Web App
problem exceptions in intialisers