During profiling my Android application using Perfetto tool I've found many cases with thread locking with message "Lock contention on thread list lock (owner tid: ...)"
Typical Perfetto screenshot:
What is the cause of the lock? Which code calls can trigger such locks?
What is the cause of the lock? Which code calls can trigger such locks?
The lock is used to manage exclusive access to ART's (the Android JVM's) internal thread list.
ART uses it in lots of places internally. Some of them (like creating/destroying threads or collecting stack traces) can be directly caused by your code. Some (like garbage collection) happen automatically. Some are even caused by the fact that you're collecting a trace. And these examples are far from exhaustive.
Should you worry about it? It's hard to say from this very zoomed-in screenshot without the larger context. 42µs is a very short time (about 1/23800th of a second), so it'd need to happen very frequently to become an actual problem.
If it turns out to be an actual problem... Generally, trying to limit your code's "global effects" (garbage creation, thread creation/exiting/interrupts, monitor usage, etc) would probably help, but the most precise way would be to add your own tracing to try to pinpoint what exactly you're doing to trigger it. Remember to check both the blocker and the blockee.