Difference between the two synchronized blocks in the doThis method:
Which should be used when?
public class AClass {
private final Object lock = new Object();
public void doThis(){
synchronized(lock){
//do stuff
}
}
}
and
public class BClass {
public void doThis(){
synchronized(this){
//do stuff
}
}
}
When should one be used over the other?