What is wrong with synchronized(this)?

Is there anything wrong with this?

synchronized(this)

I have try to do the following with a monitor object, but I get IllegalMonitoreStateException: current thread not owner

when using:

.

..

...

synchronized (MONITOR){

while (isSuspended && workerThread == thisWorker){

try{

wait();

}catch (InterruptedException x){

x =null;// ignored

}

}

.

..

...

[916 byte] By [gs03anna] at [2007-11-27 2:22:40]
# 1

You need to wait on that which you own the monitor lock.

synchronized(this)

try {

wait();

} catch (InterruptedException x) {

}

or

Object MONITOR = new Object();

...

synchronized(MONITOR)

try {

MONITOR.wait();

} catch (InterruptedException x) {

}

cooper6a at 2007-7-12 2:27:21 > top of Java-index,Core,Core APIs...