This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Threads and synchronization 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 » Threads and Synchronization
Reply Bookmark "Threads and synchronization" Watch "Threads and synchronization" New topic
Author

Threads and synchronization

ajay mv
Greenhorn

Joined: Oct 16, 2012
Posts: 2
package com.home.scjp;
i am getting IllegalMonitorStateException Exception.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 5866
    
    6

Hi, and welcome to the Ranch!

When posting code, if you UseCodeTags(←click), it will be easier to read, which will make it easier for people to help you. I've added the code tags to your original post.

As for your question, if you read the docs for that exception, it explains what causes it. I'm pretty sure it's also covered in the docs for wait(), notify(), and notifyAll(). In short, you can only call X.wait(), X.notify(), or X.notifyAll() if you're inside a synchronized (X) { ... } block, or an equivalent synchronized method. If you're getting that exception, it's because you're calling one of those methods on a object you're not synchronized on.

ajay mv
Greenhorn

Joined: Oct 16, 2012
Posts: 2
Thankyou Jeff
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Threads and synchronization
 
Similar Threads
Please explain this code
Explain output of this program
Practice Exam I: question 1
join()
deadlock?