Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When will my thread sublclass be gc'ed

 
Sharif Muhammad
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have a main server thread in its run method im creating child threads (ClientThread extends Thread):
while (true) {
//some code here....
ClientThread ct = new ClientThread(this);
vector.addElement(ct);
//more code
}
in the client thread's constructor i invoke start, and in its run method i remove it from the vector before exiting.
when will client threads be garbage collected?
thanks.
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may be collected after the thread has finished executing, and all references to it removed. There's no garantee as to if or when.
--Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic