public class SharedMapDecorator extends Object implements SharedMap, Serializable
SharedMap
. By default, simply returns the map itself as the mutex.
Subclasses may override to return a different mutex object.Constructor and Description |
---|
SharedMapDecorator(Map map)
Creates a new shared map decorator.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set |
entrySet() |
Object |
get(Object key) |
Object |
getMutex()
Returns the shared mutex that may be synchronized on using a synchronized block.
|
boolean |
isEmpty() |
Set |
keySet() |
Object |
put(Object key,
Object value) |
void |
putAll(Map map) |
Object |
remove(Object key) |
int |
size() |
String |
toString() |
Collection |
values() |
public SharedMapDecorator(Map map)
map
- the map that is shared by multiple threads, to be syncedpublic boolean containsKey(Object key)
containsKey
in interface Map
public boolean containsValue(Object value)
containsValue
in interface Map
public Collection values()
public Object getMutex()
SharedMap
synchronized (sharedMap.getMutex()) { // do synchronized work }