(In simple understandable coding. )We have studied on Chapter 29 two possible thread-safe implementations of linked list. However, even considering the implementation that provides the best performance, this data structure does not offer a very good scalability. In the paragraph Scaling Linked Lists of Section 29.3, the book hints at a technique named hand-over-hand locking, where locking is performed at a finer granularity. In detail, instead of having a single lock that can be acquired by either insert and lookup with the list granularity, a lock is added for every node of the list, so that locking can be executed at the node granularity.
Your assignment is to implement these two types of list data structures and to compare their performance (execution time) using the following workloads:
1) Starting with an empty list, two threads running at the same time insert 1 million random integers each on the same list.
2) Starting with an empty list, one thread inserts 1 million random integers, while another thread looks up 1 million random integers at the same time.
3) Starting with a list containing 1 million random integers, two threads running at the same time look up 1 million random integers each.