### Thread Safety and the Collection Classes

Like most of the IOC classes, the collection classes require thread safe operation of multithreaded access to global data. The collections may be used in a multithreaded environment, but any single instance of a collection may be referenced by only one thread at a time. Different collections may be accessed concurrently. For example, thread 1 references collection A concurrently with thread 2 referencing collection B.

The collection classes offer built-in Guard objects to simplify the explicit serialization needed to protect the collection instance. While serialization for global data is still necessary, the built-in support helps to reduce the amount of programming required. Note, however, that the locking of elements stored within a collection is the responsibility of the user and is not provided as part of collection class thread safety.

#### Restrictions

The current implementation does not provide any means to support users who want to program in a multiprocessing environment with the IBM Open Class collection classes having collection instances in shared memory regions executed. It only supports thread safety within a single process.

Due to inherent POSIX limitations, the IBM Open Class collection classes do not support the described time-out processing in AIX environment.

Introduction to the Collection Classes
Access by Key
Overview of Iteration
Backward-Compatible Items
Incompatibilities
Exceptions Defined and Used by the Collection Classes
Exception Causes

Guard Objects
Instantiating a Guard Object
Using Guard Objects
Adding an Element to a Collection
Removing an Element from a Collection
Using Cursors to Locate and Access Elements
Using Cursors to Iterate Over a Collection
Using allElementsDo and Applicators to Iterate Over a Collection
Copying and Referencing Collections