private static AtomicInteger getPoolNumberForName(String name) {
        AtomicInteger poolNumber = poolNumberMap.get(name);

        if (poolNumber == null) {
            synchronized (NamedDefaultThreadFactory.class) {
                poolNumber = poolNumberMap.get(name);

                if (poolNumber == null) {
                    poolNumber = new AtomicInteger(1);
                    poolNumberMap.put(name, poolNumber);
                }
            }
        }

        return poolNumber;
    }
An implementation of {@link ThreadFactory} that is based off of the default implementation in the java libraries
except that it inserts a custom name instead of a pool number. The name is also sequenced with a number to allow
for multiple pools with the same name to be created and still be distinguishable from each other. A threadsafe cache
is used to keep track of the sequence number for any given name.
aws-java-sdk-core/src/main/java/com/amazonaws/util/NamedDefaultThreadFactory.java