I have a function in class A. I call this function from 3 parts of my application (in different activities).
This function does critical tasks in my app and because of that, I want it will be accessible just for one of these parts in my app(I mean that all 3 parts, can't call it at the same time)
I made the function like this:
AnyType foobar(...) {
synchronized(this) {
doSomething();
}
}
does synchronized
guaranteed that no more than one request (from different classes ) at the time can execute the code of the function?
Because I call this function from different activities in my application, And in each place that I call this function I will make a new object of class A.