What does class deadlock mean?

I have the following classes:

public class User {

    public static final NonRegisteredUser NON_REG_USER = new NonRegisteredUser();

    //...

    public static class NonRegisteredUser extends User {
        //...
    }

}

And the code inspector detects this warning:

A reference to the NonRegisteredUser subclass from the superclass. The user initializer can lead to a dead end loading of classes.

What does it mean?

+4
source share
2 answers

A deadlock can only happen if you have 2 threads, and one starts to load User, and one starts to load NonRegisteredUser. There is synchronization that will lead to a deadlock, but this requires separate threads. If loading occurs in one stream, there is no deadlock, since the stream has both locks.

, . , .

+6

User.

, . , NonRegisteredUser User .

User.

, . , NonRegisteredUser User .

User.

, . , NonRegisteredUser User ...

-1

Source: https://habr.com/ru/post/1691467/


All Articles