InterviewSolution
| 1. |
What Is Lock Striping In Concurrent Programming? |
|
Answer» The concept of LOCK striping is to have separate locks for a portion of a data structure where each lock is locking on a variable sized set of independent objects. That's how ConcurrentHashMap in Java PROVIDES SYNCHRONIZATION. By default ConcurrentHashMap has 16 buckets and each bucket has its own lock so there are 16 locks too. So the threads which are ACCESSING keys in separate buckets can access them simultaneously. The concept of lock striping is to have separate locks for a portion of a data structure where each lock is locking on a variable sized set of independent objects. That's how ConcurrentHashMap in Java provides synchronization. By default ConcurrentHashMap has 16 buckets and each bucket has its own lock so there are 16 locks too. So the threads which are accessing keys in separate buckets can access them simultaneously. |
|