Sometimes you will need to look at, or modify, databases associated with other documents, but not need any explicit user input in them. You might even need to look at something associated with another document.
To merely examine databases associated with other documents, you need not lock the document, although if the document is locked in AcAp::kXWrite mode by another execution context, you will be denied access to any of its elements.
To modify databases associated with other documents, or to prevent other execution contexts from modifying them for a period of time, you must lock the document, specifying AcAp::kXWrite, AcAp::kWrite, or AcAp::kRead, depending on your intent. If the document's command processor is not quiescent, it is usually already locked, and if it mutually excludes your lock, you will be denied access.
When finished with the information associated with a document, be sure to unlock it as soon as possible, to minimize the potential for conflicts with other commands.