package org.jeecg.module.custom.ocr.utils.snow;

/**
 * @author zhangyong
 * @title: SequenceId
 * @projectName jyjz-parent
 * @description: TODO
 * @date 2021/11/13 11:14 AM
 */
public class SequenceId {
    private static Snowflake SNOW_FLAKE = null;


    static {
        Long workId = WorkId.generate();
        Long dataCenterId = DataCenterId.generate();
        SNOW_FLAKE = new Snowflake(workId, dataCenterId);
    }
    /**
     * 加锁使其多线程下能够保证其线程安全
     **/
    public synchronized static Long generate() {
        Long id = SNOW_FLAKE.nextId();
        return id;
    }
}
