package thead.safe.safe9;

import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicInteger;

public class AtomicIntegerTest {
    public static void main(String[] args) {
        MyThread myThread = new MyThread();

        Thread thread1 = new Thread(myThread);
        Thread thread2 = new Thread(myThread);
        Thread thread3 = new Thread(myThread);
        Thread thread4 = new Thread(myThread);
        Thread thread5 = new Thread(myThread);
        Thread thread6 = new Thread(myThread);
        Thread thread7 = new Thread(myThread);
        Thread thread8 = new Thread(myThread);
        Thread thread9 = new Thread(myThread);
        Thread thread10 = new Thread(myThread);

        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();
        thread6.start();
        thread7.start();
        thread8.start();
        thread9.start();
        thread10.start();

        ConcurrentSkipListMap<Integer, String> map = new ConcurrentSkipListMap<>();
        ConcurrentSkipListSet<String> stringConcurrentSkipListSet = new ConcurrentSkipListSet<>();

        CopyOnWriteArrayList<Integer> integers = new CopyOnWriteArrayList<>();
        CopyOnWriteArraySet<Integer> integerCopyOnWriteArraySet = new CopyOnWriteArraySet<>();

        new ConcurrentSkipListSet<Object>();
        new ConcurrentSkipListMap<>();
        new ConcurrentSkipListSet<>();
    }

    static class MyThread extends Thread {
        private final AtomicInteger integer = new AtomicInteger(0);

        @Override
        public void run() {
            for (int i = 0; i < 10; i++) {
                System.out.println(integer.incrementAndGet());
            }
        }
    }
}
