The documentation for java.util.concurrent.locks.ReadWriteLock states:
locks
, one for read-only operations and one for writing.
The read lock
may be held simultaneously by
multiple reader threads, so long as there are no writers. The
write lock
is exclusive.
For the following methods on a ConcurrentMap, which mutate the current instance and which lock should be acquired, if any. Feel free to review your NotThreadSafeHashTable implementation, if necessary.
V |
compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
Attempts to compute a mapping for the specified key and its
current mapped value (or
null if there is no current
mapping). |
V |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction)
If the specified key is not already associated with a value,
attempts to compute its value using the given mapping function
and enters it into this map unless
null . |
V |
get(Object key)
Returns the value to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
V |
put(K key,
V value)
Maps the specified key to the specified value in this table.
|