package thead.start.thread_9;


import thead.start.Box;

public class Test1 {
    public static void main(String[] args) {
        try {
            MyThread thread = new MyThread();
            thread.start();

            boolean list1IsInterrupted = false;
            boolean list2IsInterrupted = false;

            while (thread.isAlive()) {
                if (Box.list1.size() > 500 && !list1IsInterrupted) {
                    thread.interrupt();
                    list1IsInterrupted = true;
                }

                if (Box.list2.size() > 500 && !list2IsInterrupted) {
                    thread.interrupt();
                    list2IsInterrupted = true;
                }

                Thread.sleep(50);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
