2

Possible Duplicate:
What’s the meaning for object’s monitor in java? Why use this word?

In the java project I'm studying, I see this code block:

        // Continue once everybody is initialized
        if(allReady) {
            //AceFactory.log.fine("All ACEs are ready to start");
            readyAces.notify();
        }
    }

And readyAces is a Map<String, Boolean> AceFactory.readyAces variable.

I look up what notify() does, and I see that it does the following:

Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened

But what is meant by "this object's monitor" ? thanks

Community
  • 1
  • 1
Caffeinated
  • 11,982
  • 40
  • 122
  • 216
  • 1
    Hint: look up `synchronized` and what it can be synchronized on and how. It uses "this object's monitor" as well. –  Nov 22 '12 at 17:34
  • 1
    Not *this* object but the object on which the monitor is done. – Roman C Nov 22 '12 at 17:34
  • 1
    Exactly. It's *that* object. The same thing. –  Nov 22 '12 at 17:34
  • This is making my head feel stretched.. a good thing though./ thanks! – Caffeinated Nov 22 '12 at 17:36
  • 1
    "Monitor" is simply the term used to refer to the internal data structure that is attached to an object that has any outstanding lock activity on it. It's a bit more precise than saying "waiting on the object", but a bit more confusing as well. – Hot Licks Nov 22 '12 at 17:40
  • @pst - I'm studying `synchronized` right now! thanks! – Caffeinated Nov 22 '12 at 17:42

0 Answers0