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

Not sure if I'm closing a thread properly.

 
joe vasher
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a server program that displays the id's of each thread as it opens. When I close a client connection it closes down properly. and it closes the socket. However next time I display the id's it has incremented by 1 in the server. Should the id if the thread was released properly re use the ID of the previous client??? also I noticed that I have about a 200 bit memory leak, per task manager. the server process keeps growing everytime I close a client by about 200 bytes?

I'm not calling anything like release thread (SHOULT I)?
 
Paul Clapham
Sheriff
Posts: 21149
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way to terminate a thread is to return from the run() method.

You seem to have an expectation that the JVM will reuse numbers when it's assigning thread names. I'm not sure why you decided to expect that but no, it doesn't do that. It just does the simplest thing possible, which is to assign sequential numbers as thread names.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic