분산 식 uid 생 성기 - snowflake 자바 버 전

2021 단어 분산 시스템
package tools;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * User: FR
 * Time: 12/22/14 5:53 PM
 *     270w id    
 */
public class UUID {

    private Long HORIZON_MILLI=1419242747142L;
    private final static Integer SEQUENCE_BITS=12;
    private final static Integer WORK_ID_BITS=5;
    private final static Integer DATA_CENTER_BITS=5;
    private final static Integer MILLI_SECOND_BITS=41;
    private final static Integer MAX_SEQUENCE=-1 ^ (-1< set = new HashSet();
        while ((System.currentTimeMillis() - start)<6000){
            long id = uuid.nextId();
            set.add(id);
        }
        System.out.println(set.size());
    }
}

좋은 웹페이지 즐겨찾기