1.满足多人并发,每人固定处里数的最终一致性
public static int handle(Integer a){
System.out.println("发送优惠券"+a);
return a;
}
public static void main(String[] args) throws InterruptedException {
//优惠券集合
List<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
//闭锁发送优惠券
Map<String,Object> map = new HashMap<>();
final List<Boolean> flags = new ArrayList<>();
final List<Integer> member = new ArrayList<>();
final CountDownLatch cancelDownLatch = new CountDownLatch(3);
for(Integer a : list){
new Thread(() -> {
int num = handle(a);
if(num<3){
flags.add