#108 Counter Increment in Multiple Threads

Companies:
Sberbank
Themes:
JavaConcurrencyCode Review

What is happening here?

public static Test {

    static atomiclong value = 0;

    public static void main(String[] args) {
        for (int i = 0; i < 1000; i++) {
            new Thread(
                    () -> {
                        for (int j = 0; j < 1000; j++)
                            value.increment;
                    }
            ).start();
        }
    }
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in