This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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.