The invention is based on the idea that for a large data structure with N entries,
memory space for the locks corresponding to the entries can be saved by performing
a hashing function on a value that represents an entry into a hashed value 1 to
M. This hashed value is used to index the table of M locks. The value of M is typically
much smaller than the value of N thereby reducing memory space requirements. If
M is chosen large enough and a good hashing function is selected, problems with
collisions will be very small. Additionally, problems relating to deadlock occurring,
when the hashed value of a second entry equals the hashed value of a first entry,
are being addressed by swapping the hashed values of the first and second entries,
when the hashed value of the second entry is smaller than the hashed value of the
first entry.