public static ThreadSafeBitSet orAll(ThreadSafeBitSet... bitSets) {
        if(bitSets.length == 0)
            return new ThreadSafeBitSet();

        int log2SegmentSize = bitSets[0].log2SegmentSize;
        int numLongsPerSegment = bitSets[0].numLongsPerSegment;

        ThreadSafeBitSetSegments segments[] = new ThreadSafeBitSetSegments[bitSets.length];
        int maxNumSegments = 0;

        for(int i=0;i<bitSets.length;i++) {
            if(bitSets[i].log2SegmentSize != log2SegmentSize)
                throw new IllegalArgumentException("Segment sizes must be the same");

            segments[i] = bitSets[i].segments.get();
            if(segments[i].numSegments() > maxNumSegments)
                maxNumSegments = segments[i].numSegments();
        }

        ThreadSafeBitSetSegments newSegments = new ThreadSafeBitSetSegments(maxNumSegments, numLongsPerSegment);

        AtomicLongArray segment[] = new AtomicLongArray[segments.length];

        for(int i=0;i<maxNumSegments;i++) {
            for(int j=0;j<segments.length;j++) {
                segment[j] = i < segments[j].numSegments() ? segments[j].getSegment(i) : null;
            }

            AtomicLongArray newSegment = newSegments.getSegment(i);

            for(int j=0;j<numLongsPerSegment;j++) {
                long value = 0;
                for(int k=0;k<segments.length;k++) {
                    if(segment[k] != null)
                        value |= segment[k].get(j);
                }
                newSegment.set(j, value);
            }
        }

        ThreadSafeBitSet or = new ThreadSafeBitSet(log2SegmentSize);
        or.segments.set(newSegments);
        return or;
    }
@Test
    public void testOrAll() {
        BitSet bSet = new BitSet();

        ThreadSafeBitSet[] tsbSets = new ThreadSafeBitSet[3];
        int[] ordinals = new int[] { 1, 5, 10 };

        // init
        int i = 0;
        for (int ordinal : ordinals) {
            tsbSets[i] = new ThreadSafeBitSet();
            tsbSets[i].set(ordinal);
            i++;

            bSet.set(ordinal);
        }

        // validate content
        ThreadSafeBitSet result = ThreadSafeBitSet.orAll(tsbSets);
        Assert.assertEquals(bSet.cardinality(), result.cardinality());
        Assert.assertEquals(bSet, result.toBitSet());
    }