• Post Reply Bookmark Topic Watch Topic
  • New Topic

URGENT !!! How to Kill Threads... Fatal Error  RSS feed

 
Sandeep. Oza
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
In my java application in one method(say abd()) of a class, i have start new thread every time when my jsp page calls that method abd().
abd(){
mThread.start();
}
But i am not destrying this thread after using it. So... application gives "Fatal Error..." after about 900 iterations ( calling this method)
This is because i am not stop threads after use..( I think)..
So.. what shall i do..??? how to recognize which threads .. how many threads are live...?? and so how to kill them...???
Pl. help.
Thanks in Advance.
Sandeep Oza
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should not kill threads yourself. In fact, the method for stopping a thread (stop()) is deprecated. One way to handle this in a cleaner way is to place a while loop in your run() method. It is basically a flag, so the thread will run until you set that flag to a different value. The execution will finish the while loop (or any other loop) and the run() method will finish.
also, have a look at this article.
[ August 14, 2003: Message edited by: Andres Gonzalez ]
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, why are you doing this?
 
Sandeep. Oza
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andrez,
Actually i am listening to a port to socket... as i get any message.. I am starting my further process using a new thread... this thread remains alive till i got reply message from another application/socket.. then i wan to stop this thread.. let me try using your solution..
Sandeep Oza
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!