aspose 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
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9191
    
    2

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: SOS: i have some questions about Thread
 
Similar Threads
Using non-static object as lock in Threads PRoblem
Thread synchonization
Confusion with this Output
Thread.yield()
Question on multithreading from Sierra/Bates Chapter 9, Question 16