• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IllegalMonitorStateException

 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i created these classes and got that exception. i tried using the synchronized(this) statement instead and it worked... it's a bit confusing because letters and numbers are two diff objects and i'm wondering why my first aproach didn't work... hewp!
 
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you look at the API doc. at the Object.notify method for example, you can find the following:
A thread becomes the owner of the object's monitor in one of three ways:
-By executing a synchronized instance method of that object.
-By executing the body of a synchronized statement that synchronizes on the object.
-For objects of type Class, by executing a synchronized static method of that class.
So, what does this mean: That you have to own the thread�s monitor for using notify, for example. Read the API doc carefully for a deep detail of the following methods from Object: notify, wait, notifyAll.
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i see!!! i should have specifically used the letters.notify()/letters.notifyAll() and numbers.notify()/numbers.notifyAll() instead!
thanks a lot Marcela Blei!!!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic