Here you can find the source of getSid(BigDecimal total, AtomicLong sid)
public static BigDecimal getSid(BigDecimal total, AtomicLong sid)
//package com.java2s; /*/*from w ww. j a va 2s. c o m*/ * Copyright(C) 2011-2012 Alibaba Group Holding Limited * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Authors: * wentong <wentong@taobao.com> */ import java.math.BigDecimal; import java.util.concurrent.atomic.AtomicLong; public class Main { public static BigDecimal getSid(BigDecimal total, AtomicLong sid) { BigDecimal ret = new BigDecimal(sid.getAndIncrement()); if (ret.longValue() > total.longValue()) { sid.set(1); } return ret; } }