An architecture for a read/write thread lock is provided for use in a
computing environment where several sets of computer instructions, or
"threads," can execute concurrently. The disclosed thread lock allows
concurrently-executing threads to share access to a resource, such as a
data object. The thread lock allows a plurality of threads to read from a
resource at the same time, while providing a thread exclusive access to
the resource when that thread is writing to the resource. The thread lock
uses critical sections to suspend execution of other threads when one
thread needs exclusive access to the resource. Additionally, a technique
is provided whereby the invention can be deployed as constructors and
destructors in a programming language, such as C++, where constructors
and destructors are available. When the invention is deployed in such a
manner, it is possible for a programmer to issue an instruction to lock a
resource, without having to issue a corresponding unlock instruction.