File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes errrrr Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "errrrr" Watch "errrrr" New topic


Dishi Malhotra

Joined: Dec 13, 2000
Posts: 22
This code is giving me error : I don't know what is it
(This code is written for how much time the is open)

I added code tags for you.
[This message has been edited by Randall Twede (edited March 05, 2001).]
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

You can learn about UBB tags here
If you cant get an answer here. I will move it to the sockets forum tomorrow.

Visit my download page
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Originally posted by Dishi Malhotra:
t1 = new Thread();
t1 = null;

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().

"JavaRanch, where the deer and the Certified play" - David O'Meara
Dishi Malhotra

Joined: Dec 13, 2000
Posts: 22
Candy i can't get u what u want to say so plz explain
Siva Prasad
Ranch Hand

Joined: Feb 22, 2001
Posts: 104
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
Siva Prasad
[This message has been edited by Siva Prasad (edited March 07, 2001).]
I agree. Here's the link:
subject: errrrr
It's not a secret anymore!