• Post Reply Bookmark Topic Watch Topic
  • New Topic

thread doubt  RSS feed

 
Murali Ravipudi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
say I have a class implementing Runnable, call it 'A'
when I have to use it, I do something like
A a = new A();
Thread t = new Thread(a);
runflag = true;
t.start();
...
runflag = false;
t = null;
what happens to the thread object created and assigned to t? will it still hold a reference to 'a' and hang around in memory?
if so, when ever I do such, I will leave a dead thread object lying around, wasting memory...
some one?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you do
t = null;
you are suggesting the garbage collector to take the thread object which is referenced by t , off the memory. So there won't be any thread object left after the gc takes the memory.
Sanjay
 
Murali Ravipudi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh, I was confused.
thanks for that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!