Allow external locks to work with threads

External locks by themselves do not work with greenthreads in a
single process because multiple greenthreads are allowed to grab
the file lock at once.  Previous lockutils code also grabbed a
local semaphore for external locks so this was not a problem, but
after the recent refactoring that was no longer happening, which
caused some issues in other projects.

Since it's less confusing to have external locks also work as
internal locks, this change switches the behavior back to what it
was before.  It also adds some test cases to verify these external
lock behaviors.

Change-Id: If66d358c7bd3960c1cc9c8d392fcc158963943bc
Merge "Allow external locks to work with threads"