public class Solution {
    public static void main(String[] args) {
        new NoteThread().start();
        new NoteThread().start();
    }

//наследую NoteThread от класса Thread
    public static class NoteThread extends Thread{
        NoteThread(){
            super();
        }
//определяю index равный 1000
        public int index = 1000;
        public boolean marker = false;


        public void run(){
            try{
//запускаю цикл и в нем выполняются указанные в задаче методы
               while (!marker){
                    Note.addNote(getName()+"-Note" + index);
                    sleep(1);
                    Note.removeNote(getName());

                   index++;
                   if(index == 1000){
                       marker = true;
                   }
               }

//но несмотря на внешне правильную логику, решение не проходит(((
            }catch (InterruptedException e){

            }
        }
    }

    public static class Note {

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

        public static void addNote(String note) {
            notes.add(0, note);
        }

        public static void removeNote(String threadName) {
            String note = notes.remove(0);
            if (note == null) {
                System.out.println("Другая нить удалила нашу заметку");
            } else if (!note.startsWith(threadName)) {
                System.out.println("Нить [" + threadName + "] удалила чужую заметку [" + note + "]");
            } else {
                System.out.println("Нить [" + threadName + "] удалила свою заметку [" + note + "]");
            }
        }
    }
}