import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;

public class CountDownLatchTest implements Runnable{
	private static Logger logger= LoggerFactory.getLogger(CountDownLatchTest.class);
	final AtomicInteger number = new AtomicInteger();
    volatile boolean bol = false;
    private MemberUnionidRelatedApiService memberUnionidRelatedApiService;
    private String wxUserId;
    private CountDownLatch countDownLatch;
    public CountDownLatchTest(MemberUnionidRelatedApiService memberUnionidRelatedApiService,String wxUserId,CountDownLatch countDownLatch){
    	this.memberUnionidRelatedApiService = memberUnionidRelatedApiService;
    	this.wxUserId = wxUserId;
    	this.countDownLatch = countDownLatch;
    }
    
    @Override
    public void run() {
        try {
            // 线程等待
        	countDownLatch.await();
        	long startTime = System.currentTimeMillis();
            List<String> res = memberUnionidRelatedApiService.listSelfExterialList("ca66a01b79474c40b3e7c7f93daf1a3b", wxUserId);
            System.out.println(JSON.toJSONString(res));
            

            long endTime = System.currentTimeMillis();
            System.out.println(Thread.currentThread().getName() + " ended at: " + endTime + ", cost: " + (endTime - startTime) + " ms.");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
