Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

thread questions

 
Robert Kennedy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an http file upload class which implements runnable. I am contemplating keeping the thread alive in the run method for reuse vs creating a new object for each file, which implies creating a new thread for each file. Are there any issues with the later approach? Once the thread exits the run loop it is ready for garbage collection.


Also, is it possible to call start on a thread more than once?
Thanks
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a lot of overhead in thread create/destroy so you really don't want to do that if at all possible.

The preferred method is to create a queue and have a thread pool (even if it's only one thread) fetch a request from the queue, process the request and fetch the next request.

No, you cannot re-start a thread.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!