First, use internal classes to add inheritance relationships
Class A {protected class B extends a {// public B () {system. out. println ("This is B constructor") ;}} public B = new B (); Public A () {// system. out. println ("this is a constructor") ;}} public class testinnerclass {public static void main (string ARGs []) {New ();}}
Second, use the normal class to add inheritance
Class A {public testdeadlock T = new testdeadlock ();} public class testdeadlock extends a {public static void main (string ARGs []) {New ();}}
Or:
Class A {public a () {testdeadlock T = new testdeadlock () ;}} public class testdeadlock extends a {public static void main (string ARGs []) {New ();}}
Third, it can be implemented without constructors or inheritance.
Class blocked {public interrupt = new interrupt ();} public class interrupt {blocked B = new blocked (); public static void main (string [] ARGs) {New blocked ();}}
Conclusion: The inheritance relationship is used to bring deadlocks to the parent and child classes.
Instantiating a subclass in the parent class is the root cause of deadlock.
In fact, resources compete with each other to form an endless loop