Rather than saying it a doubt, I would like to say it, a clarification!
When one
thread starts to execute a synchronized method, does it implicitly means that, IT HAS GOT THE LOCK ON THE OBJECT, whose synchronized method is invoked ?
Consider the following code :
===
Here the output is always
100
100
100
100
...
===
Is it because that, the thread t1 enters its synchronized run method, thus acquiring a lock on 's' object of Slave Class. While the main thread is not able to acquire the lock on the same object and thus not able to execute "s.setPrice(200);" ... Am I right?
[ October 30, 2004: Message edited by: Barry Gaunt ]