Example 4-6 modifies the previous list structure by converting it into a circular list. There is no longer a distinguished head node; now a thread might be associated with a particular node and might perform operations on that node and its neighbor. Note that lock hierarchies do not work easily here because the obvious hierarchy (following the links) is circular.
typedef struct node2 { int value; struct node2 *link; pthread_mutex_t lock; } node2_t;
Here is the C code that acquires the locks on two nodes and performs an operation involving both of them.