Sobes.tech
Junior — Senior

Analysis of synchronized in a recursive method

livecode

Task condition

It is necessary to carefully study the presented fragment and identify hidden pitfalls in its operation.

public class Incrementor {
    int value = 0;

    public synchronized void inc() {
        if (value < 10) {
            value++;
            inc();
        }
    }
}

new Incrementor().inc();