The Artima Developer Community
Sponsored Link

Java Answers Forum
Inside the JVM -- Threading

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Will McQueen

Posts: 3
Nickname: will608
Registered: Jul, 2006

Inside the JVM -- Threading Posted: Jul 16, 2006 11:11 AM
Reply to this message Reply
Advertisement
Hi,

I'm not sure if this is the correct forum for questions relating to Bill Venners' book, "Inside the JVM" (2nd ed)... which I just finished yesterday (except for the appendix). What an excellent book!

p.522 desribes the areturn instr. It says, "If the current method is synchronized and the current thread does not own the monitor acquired or reentered when the method was invoked, the virtual machine throws IllegalMonitorStateException". This idea doesn't make sense to me yet, given my understanding below...

Now, I understand that a synchronized statement is different from a synchronized method... a synchronized statement uses "monitorenter" and "monitorexit" in the bytecodes, but a synchronized method doesn't. Eg, on p509: "The Java virtual machine does not use any special opcodes to invoke or return from synchronized methods." Then p511 re-inforces this from an example: "If this method completes abruptly, just as if it completes normally, the virtual machine will release the lock on the 'this' object automatically".

So the question...
If the current method is synchronized and has no monitorenter or monitorexit instrs (and for simplicity, does not itself invoke any methods), then how could an "IllegalMonitorStateException" possibly be thrown since the JVM itself (not the bytecodes) is responsible for automatically entering and the releasing the monitor belonging to the synchronized method?

--Will

Topic: How can I limit the number of characters entered into a JTextField? Previous Topic   Next Topic Topic: Thread question

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use