Q1: The following 3 options will work.(regardless of synchronized comm() ). But which object instance is locked?
Option1:public synchronized void run(){
This will lock the object
test.
Option2:public void run(){
synchronized(x){
for (int i = 0; i<10; i++){
This will lock the object instance x.
Option3: public void run(){
synchronized(this){
for (int i = 0; i<10; i++){
This will lock the object test.
-----------------
Q2:If Thread.currentThread() returns current thread should this same as option3 above (using this)?
Q3:Ruben in your response "the MultiUseMe instance referred to by x (do synchronized(this)"-How can you get lock on object instance x by using 'do synchronized(this)'?