V
Vikram
Hi,
Consider the code below
List lockedObject = new ArrayList();
........
.......
synchronized(lockedObject){
........
........
}
I have a doubt. In the above code we say that a lock has been applied
on the List object. What does it actually mean ?
Does it mean that if any thread is in the synchronized block, no other
thread can change the variable "lockedObject" ?
Also when we have a code as below
public synchronized void bar(){
.....
....
}
we say it is same as
public void bar(){
synchronized(this){
....
}
}
What does this mean ? Does it mean that when a thread is invoking
method "bar", no other thread can make changes to any public static
member of the class and no other method can be invoked ?
Consider the code below
List lockedObject = new ArrayList();
........
.......
synchronized(lockedObject){
........
........
}
I have a doubt. In the above code we say that a lock has been applied
on the List object. What does it actually mean ?
Does it mean that if any thread is in the synchronized block, no other
thread can change the variable "lockedObject" ?
Also when we have a code as below
public synchronized void bar(){
.....
....
}
we say it is same as
public void bar(){
synchronized(this){
....
}
}
What does this mean ? Does it mean that when a thread is invoking
method "bar", no other thread can make changes to any public static
member of the class and no other method can be invoked ?