Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

errrrr

 
Dishi Malhotra
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code is giving me error : I don't know what is it
(This code is written for how much time the rediff.com is open)

I added code tags for you.
[This message has been edited by Randall Twede (edited March 05, 2001).]
 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can learn about UBB tags here http://www.javaranch.com/ubb/ubbcode.html
If you cant get an answer here. I will move it to the sockets forum tomorrow.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dishi Malhotra:
t1 = new Thread();
t1 = null;
t1.start();


So you create a new thread. They you take way the only reference to it by setting the variable referencing it to mull. Then you start it???
Perhaps I am missing something, but looks to me like t1 is food for the gc().
 
Dishi Malhotra
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Candy i can't get u what u want to say so plz explain
 
Siva Prasad
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dishi
What Cindy was trying to say ...
when you say
t1 = new Thread();
a new Thread Object is created referenced by t1.
immediately you are setting this t1 to null which means there is no object associated with t1 now when you say this t1 = null;
After that you are trying to call a method start() [t1.start()] for this reference which doesnot have any association with any object. So as a result you get a NullPointerException when u try to access this function.
During the course of time, since the Thread object created has no reference, this will be destroyed by GarbageCollector.
Hope this clears your doubt
cheers
Siva Prasad
[This message has been edited by Siva Prasad (edited March 07, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic