I am getting StackOverflowError while executing below program:
Error Description:
Exception in
thread "main" java.lang.StackOverflowError
at java.security.AccessControlContext.optimize(Unknown Source)
at java.security.AccessController.getContext(Unknown Source)
at java.lang.Thread.init(Unknown Source)
at java.lang.Thread.<init>(Unknown Source)
at com.threadEx.ThreadEx2.<init>(ThreadEx2.java:3)
at com.threadEx.ThreadEx2.<init>(ThreadEx2.java:9)
at com.threadEx.ThreadEx2.<init>(ThreadEx2.java:9)
Now if At Line 1 where I have instantiated an object of Class, if the same program is run with below statement,
public static ThreadEx2 ex = new ThreadEx2();
No such error is observed. Can somebody help me on solving on this.
[Edit - added code tags - see UseCodeTags for details]