package com.yida.data;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import lombok.AllArgsConstructor;
import lombok.Data;

public class test {

    @Test
    public void test() {
        ExecutorService service = new ThreadPoolExecutor(10, 10, 1000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
        List<d> list = new ArrayList<>();
        list.add(new d("1"));
        list.add(new d("2"));
        list.add(new d("3"));
        for (d d : list) {
            service.execute(() -> {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + ":" + d.getL());
                }
            });
        }
        while (true) {
            //if (list.size() == 1) {
            //    break;
            //}
        }
    }

    @Data
    @AllArgsConstructor
    class d {
        private String l;
    }
}
