This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SOS: i have some questions about Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "SOS: i have some questions about Thread" Watch "SOS: i have some questions about Thread" New topic
Author

SOS: i have some questions about Thread

kevin saber
Greenhorn

Joined: Mar 07, 2010
Posts: 21


this will cause NullPointerException when i run it, but i don't understand why...
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9400
    
  20

In the go method, the two Test5 objects with which you create 2 threads both have Chicks as null, so calling yack in the run method causes NPE. Try this


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
kevin saber
Greenhorn

Joined: Mar 07, 2010
Posts: 21
oh~~ i would have simply thought that c have pointed to an object by mistake as line 9 showed.
thank you!!!
 
Have you checked out Aspose?
 
subject: SOS: i have some questions about Thread
 
It's not a secret anymore!