Thanks to Mark's comment, pointing me to https://en.wikipedia.org/wiki/File_locking#Lock_files which says
Shell scripts and other programs often use a strategy similar to the use of file locking: creation of lock files, which are files whose contents are irrelevant (although often one will find the process identifier of the holder of the lock in the file) and whose sole purpose is to signal by their presence that some resource is locked. A lock file is often the best approach if the resource to be controlled is not a regular file at all, so using methods for locking files does not apply. For example, a lock file might govern access to a set of related resources, such as several different files, directories, a group of disk partitions, or selected access to higher level protocols like servers or database connections.
In "A lock file is often the best approach if the resource to be controlled is not a regular file at all, using methods for locking files does not apply",
why is a lock file the best if the resource is not a regular file? I can't see a lock file would be different whether the protected resource is a regular file or not.
What does "using methods for locking files does not apply" mean, and why? Isn't that opposite to "A lock file is often the best approach"? Or is the method for locking files different from the lock file approach ?