Bookmark Topic Watch Topic
  • New Topic

can the following code produces Null pointer exception?‏  RSS feed

 
khan gul
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 3179
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please dont create multiple posts for the same query. Lets continue here.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!