1. In a computer system that has at least one processor with at least one atomic instruction for atomically changing the contents of a data word, and a plurality of threads of execution running concurrently on the processor(s), a condition variable comprising: computer-executable code for synchronizing the threads; a head list and a tail list together indicating which threads, if any, are currently blocked on the condition variable, wherein the head list links threads in arrival order and the tail list links threads in reverse arrival order, the head list and the tail list together indicating an arrival order for any currently blocked threads; and a data structure comprising: a head pointer to a first blocked thread in the head list, if any; a tail pointer to the last blocked thread in the tail list, if any; a wait counter indicating how many threads are currently linked in the data structure; and a signal counter indicating how many times the condition variable has been signaled for waiting threads that are currently linked in the data structure, wherein the head pointer, the tail pointer, the wait counter and the signal counter all comprise portions of a single data word that can be atomically updated using a single atomic instruction, the data word comprising a unit of data bits addressable by read-modify-write primitives, the data bits being partitioned into four groups of data bits, a first group constituting the head pointer, a second group constituting the tail pointer, a third group constituting the wait counter and the fourth group constituting the signal counter, wherein when a wait function is invoked for a first thread, the first thread is linked into the data structure and the wait counter is incremented, both in a single atomic operation using a single atomic instruction, and wherein when a second thread is to be dequeued, the second thread is removed from the data structure, the wait counter is decremented and the signal counter is decremented, all three in a single atomic operation using a single atomic instruction.