org.apache.commons.collections.bag
Class SynchronizedBag
- Bag, Collection, Serializable
public class SynchronizedBag
Decorates another
Bag
to synchronize its behaviour
for a multi-threaded environment.
Methods are synchronized, then forwarded to the decorated bag.
Iterators must be separately synchronized around the loop.
This class is Serializable from Commons Collections 3.1.
$Revision: 1.8 $ $Date: 2004/06/03 22:02:12 $
add , addAll , clear , contains , containsAll , decorate , equals , hashCode , isEmpty , iterator , remove , removeAll , retainAll , size , toArray , toArray , toString |
SynchronizedBag
protected SynchronizedBag(Bag bag)
Constructor that wraps (not copies).
bag
- the bag to decorate, must not be null
SynchronizedBag
protected SynchronizedBag(Bag bag,
Object lock)
Constructor that wraps (not copies).
bag
- the bag to decorate, must not be nulllock
- the lock to use, must not be null
add
public boolean add(Object object,
int count)
- add in interface Bag
decorate
public static Bag decorate(Bag bag)
Factory method to create a synchronized bag.
bag
- the bag to decorate, must not be null
getBag
protected Bag getBag()
Gets the bag being decorated.
getCount
public int getCount(Object object)
- getCount in interface Bag
remove
public boolean remove(Object object,
int count)
- remove in interface Bag
Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.