Application

Report a typo

Take a look at the code snippet below and pick the right option about numbers size

class ConcurrentQueueTest {
    public static void main(String[] args) throws InterruptedException {
        Queue<Integer> numbers = new ConcurrentLinkedQueue<>();
        addNumbers(numbers);

        Thread thread1 = new Thread(() -> pollNumbers(numbers));
        Thread thread2 = new Thread(() -> pollNumbers(numbers));

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

        thread1.join();
        thread2.join();

        System.out.println(numbers.size()); // ?
    }

    private static void addNumbers(Queue<Integer> target) {
        for (int i = 0; i < 100_000; i++) {
            target.add(i);
        }
    }

    private static void pollNumbers(Queue<Integer> target) {
        for (int i = 0; i < 50_000; i++) {
            target.poll();
        }
    }
}
Select one option from the list
___

Create a free account to access the full topic