File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes can the following code produces Null pointer exception?‏ Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply locked New topic
Author

can the following code produces Null pointer exception?‏

khan gul
Greenhorn

Joined: Jan 27, 2011
Posts: 29
Hi,
I have a question on the following code. Is it possible that the following code can throw Null Pointer Exception?


can the following code produces Null pointer exception?



Since Test class is being added dynamically to ByValue class and Test is a static field in the ByValue, is it possible that when one Thread RESET this static Test field the other thread sees a NULL value?

From Time line point of view, say Thread T3 run() first and instantiate ByValue first and then set Test object to static Test field. But before calling byValue.getTest(), Thread T4 run() and reset a new Test object in the ByValue. Question I have is it possible that T3 can get Null Pointer Exception when it calls byValue.getTest().getName();

Thanks,
Mohamed Sanaulla
Bartender

Joined: Sep 08, 2007
Posts: 2693

Please dont create multiple posts for the same query. Lets continue here.


Mohamed Sanaulla | My Blog
 
 
subject: can the following code produces Null pointer exception?‏
 
Threads others viewed
some problems regd threads as in velmurugan's notes
java.rmi.UnmarshalException?
java.rmi.UnmarshalException?
ORA-02291: integrity constraint, can not find parent key
can the following code produces Null pointer exception?‏
IntelliJ Java IDE