void itkDCMTKDataImageReaderPrivate::initialiseStatic()
{
    if ( ! mutex) {
        QMutex * m = new QMutex();
        if ( ! mutex.testAndSetOrdered(NULL, m))
            delete m;
    }

    QMutexLocker lock(mutex);

    if ( ! ioThreads )
        ioThreads = new QList<QThread*>();

    if ( ! ioPointers )
        ioPointers = new QList<itk::DCMTKImageIO::Pointer>();
}
const QHash<int, QString> &TCriteriaData::formats()
{
    QHash<int, QString> *ret = formatVector.fetchAndAddOrdered(0);

    if (!ret) {
        ret = new QHash<int, QString>();
        ret->insert(TSql::Equal, "=%1");
        ret->insert(TSql::NotEqual, "<>%1");
        ret->insert(TSql::LessThan, "<%1");
        ret->insert(TSql::GreaterThan, ">%1");
        ret->insert(TSql::LessEqual, "<=%1");
        ret->insert(TSql::GreaterEqual, ">=%1");
        ret->insert(TSql::IsNull, " IS NULL");
        ret->insert(TSql::IsNotNull, " IS NOT NULL");
        ret->insert(TSql::Like, " LIKE %1");
        ret->insert(TSql::NotLike, " NOT LIKE %1");
        ret->insert(TSql::LikeEscape, " LIKE %1 ESCAPE %2");
        ret->insert(TSql::NotLikeEscape, " NOT LIKE %1 ESCAPE %2");
        ret->insert(TSql::ILike, " ILIKE %1");
        ret->insert(TSql::NotILike, " NOT ILIKE %1");
        ret->insert(TSql::ILikeEscape, " ILIKE %1 ESCAPE %2");
        ret->insert(TSql::NotILikeEscape, " NOT ILIKE %1 ESCAPE %2");
        ret->insert(TSql::In, " IN (%1)");
        ret->insert(TSql::NotIn, " NOT IN (%1)");
        ret->insert(TSql::Between, " BETWEEN %1 AND %2");
        ret->insert(TSql::NotBetween, " NOT BETWEEN %1 AND %2");
        ret->insert(TSql::Any, "ANY (%1)");
        ret->insert(TSql::All, "ALL (%1)");

        if (!formatVector.testAndSetOrdered(0, ret)) {
            delete ret;
            ret = formatVector.fetchAndAddOrdered(0);
        }
    }
    return *ret;
}