⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections.bag

Class SynchronizedSortedBag

java.lang.Object
|
+--org.apache.commons.collections.collection.SynchronizedCollection
   |
   +--org.apache.commons.collections.bag.SynchronizedBag
      |
      +--org.apache.commons.collections.bag.SynchronizedSortedBag

All Implemented Interfaces:
Collection, Bag, SortedBag


public class SynchronizedSortedBag
extends SynchronizedBag
implements SortedBag

Decorates another SortedBag 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.

Since:
Commons Collections 3.0
Author:
Stephen Colebourne

Constructor Summary

SynchronizedSortedBag(SortedBag bag)

Constructor that wraps (not copies).

SynchronizedSortedBag(Bag bag, Object lock)

Constructor that wraps (not copies).

Method Summary

synchronized Comparator

comparator()

static SortedBag

decorate(SortedBag bag)

Factory method to create a synchronized sorted bag.

synchronized Object

first()

SortedBag

getSortedBag()

synchronized Object

last()

Constructor Details

SynchronizedSortedBag

protected SynchronizedSortedBag(Bag bag, Object lock)

Constructor that wraps (not copies).

Parameters:
bag - the bag to decorate, must not be null
lock - the lock to use, must not be null
Throws:
- if bag is null

SynchronizedSortedBag

protected SynchronizedSortedBag(SortedBag bag)

Constructor that wraps (not copies).

Parameters:
bag - the bag to decorate, must not be null
Throws:
- if bag is null

Method Details

comparator

public synchronized Comparator comparator()


decorate

public static SortedBag decorate(SortedBag bag)

Factory method to create a synchronized sorted bag.

Parameters:
bag - the bag to decorate, must not be null
Throws:
- if bag is null

first

public synchronized Object first()


getSortedBag

protected SortedBag getSortedBag()


last

public synchronized Object last()