What is a monitor ?

R

Razvan

A simpler practical definition:


"Any object that has synchronized code."


Regards,
Razvan
 
T

Thomas G. Marshall

Razvan coughed up:
A simpler practical definition:


"Any object that has synchronized code."


Regards,
Razvan


No.

A "monitor" is conceptually more /owned/ or /held/ by an object, it is not
the object itself.

Take for evidence the following java documentation for (Object).notify in
the java source file mumble/java/lang/Object.java.

public final void notify()

Wakes up a single thread that is waiting on
this object's monitor. [...]

This terminology is used throughout.
 
M

Mike Schilling

Razvan said:
A simpler practical definition:


"Any object that has synchronized code."

It's a lock used to ensure that the execution of a section of code is
restricted to one thread at a time. (A section of code protected by a
monitor is called a "critical section.") In Java, each object owns a
monitor, but the object is not itself a monitor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top