I noticed that there are lots of use of the methods named '*Locked()' while I am looking through Android framework codes. I wonder what 'Locked' means and what features those methods are reflecting to.
For example, there are a number of methods named in such way in Activity related classes.
android/frameworks/base/services/java/com/android/server/am/ActivityStack.java
Thank you for your help in advance! :)
That means the method is multithread-safe.
You can find code from ActivityManagerService.class like below:
synchronized (this) {
dumpActivitiesLocked(fd, pw, args, opti, true, dumpClient, null);
}
or some code like that:
synchronized (this) {
methodA();
}
methodA() {
dumpActivitiesLocked(fd, pw, args, opti, true, dumpClient, null);
}
So the methods named *Locked means the method is not multithread-safe, in ActivityManagerService.class, you should use synchronized (this) make sure the multithread-safe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With