This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Let's use only the relevant (for your question) part of code ( formatted so it's easier to read):
The two threads you start at line 11 and 12 do not use your current ChickYack instance you create at line 10.
Each creates its own, new instance: new Thread(new ChickYack()) ...
Since c is only declared (line 3) => it has the default value which is null.
That means, at line 16 c is null => a NullPointerException will be thrown.
Joined: Feb 05, 2009
Thanks for your reply .... I think i got the explanation.
Since it creates entirely new objects(in line 11,12) c will be null for these objects.