File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 9280
    
  17

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!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SOS: i have some questions about Thread
 
Similar Threads
Confusion with this Output
Thread synchonization
Thread.yield()
Using non-static object as lock in Threads PRoblem
Question on multithreading from Sierra/Bates Chapter 9, Question 16