public class Solution {

    public static volatile Note note = new Note();
    public static volatile AtomicInteger i = new AtomicInteger(0);

    public static void main(String[] args) throws InterruptedException {
        NoteThread noteThread1 = new NoteThread();
        Thread thread1 = new Thread(noteThread1);
        NoteThread noteThread2 = new NoteThread();
        Thread thread2 = new Thread(noteThread2);

        thread1.start();
        thread2.start();

        while(note.notes.size() < 99) {}

        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

        for (int j = 0; j < note.notes.size(); j++) {
            System.out.println(j + "-" + note.notes.get(j));
        }
    }

    public static class Note {

        public volatile List<String> notes = new ArrayList<String>();

        public synchronized void addNote(int index, String note) {
            System.out.println("БСйчас Π±ΡƒΠ΄Π΅Ρ‚ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½Π° Π·Π°ΠΌΠ΅Ρ‚ΠΊΠ° [" + note + "] На ΠΏΠΎΠ·ΠΈΡ†ΠΈΡŽ " + index + " " + Thread.currentThread().getName());
            notes.add(index, note);
            //System.out.println("Π£ΠΆΠ΅ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½Π° Π·Π°ΠΌΠ΅Ρ‚ΠΊΠ° [" + note + "]" + index +  " " + Thread.currentThread().getName());
        }

        public void removeNote(int index) {
            System.out.println("БСйчас Π±ΡƒΠ΄Π΅Ρ‚ ΡƒΠ΄Π°Π»Π΅Π½Π° Π·Π°ΠΌΠ΅Ρ‚ΠΊΠ° с ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ " + index);
            String note = notes.remove(index);
            System.out.println("Π£ΠΆΠ΅ ΡƒΠ΄Π°Π»Π΅Π½Π° Π·Π°ΠΌΠ΅Ρ‚ΠΊΠ° [" + note + "] с ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ " + index);
        }
    }

    static class NoteThread implements Runnable {
        //public Note note = new Note();

        @Override
        public void run() {
            while(i.get() < 100) {
                note.addNote(i.get(), "note" + i.get());
                i.incrementAndGet();
            }
       }
    }
}