If I write synchronized(this)
in two function of the same java class, but these two functions are maybe called by two threads, does this code still work?
Some fake code maybe looks like:
class A {
public funA()
synchronized (this) {
// do some things here;
}
}
public funB() {
synchronized (this) {
// do other things here;
}
}
}
Or do I need to add a variable to do it?