[Soot-list] questions on synchronization

John Jorgensen jorgnsn at lcd.uregina.ca
Sun Apr 23 15:03:52 EDT 2006


>>>>> "mbatch" writes:

    mbatch> On Sun, April 23, 2006 12:33 pm, Arnab De wrote:

    >> My question is where there is a exception throwing in the
    >> synchronizd methods?

    mbatch> The exception is the implicit
    mbatch> IllegalMonitorStateException - since you are using
    mbatch> the synchronized construct in java.. When a thread
    mbatch> tries to unlock an object, for example, that it has
    mbatch> never locked, it will throw an
    mbatch> IllegalMonitorStateException. Just part of the cost
    mbatch> of doing business with locks and threads..

I think the possibilities may be broader than that. In the absence
of interprocedural analysis, you have to assume that
System.out.println(), yield(), and partner.hugBack() might all
throw some exception.  And even if an interprocedural analysis
does prove that none of those procedures can throw an exception,
there's the possibility that some other thread might call the
deprecated Thread.stop() method to deliver an arbitrary exception
to this thread.

Should any such event cause an exception to be raised while
executing within the synchronized block, the block's exception
handler assures that the lock will be released before the
exception is passed on up the call stack.  See sections 3.11.1
and 7.14 of the JVM specification
(http://java.sun.com/docs/books/vmspec/2nd-edition/html/VMSpecTOC.doc.html)



More information about the Soot-list mailing list