hi all, I am working on webappliction , i started one thread in one jsp bean class, when i started i get the thread name and save it in database . The problem is ,when i wanted to stop that thread from some other page by getting this thread name from database.Because the thread is running and i wanted to stop that by the name.
My question is, Is there any way to get the reference of that theard that i started earlier by enter the name and then stop it.
Please help me ,if any body have solution for that.
Jyotisree, you shouldn't be trying to stop a thread anyway. All the stop() methods in the Thread class are deprecated now. This means the stop() methods should no longer be called, from any thread. Ever! [ Stopping a thread could cause an indeterminate state in the resource guarded by your thread, because a stopped thread immediately releases all of its locks and this means another thread could jump in and grab the locks, and there is no repeatable way for you to tell in advance which thread grabs the lock. Leading to an indeterminate state for the resource. ] Suggest you go away and think about your design. Each thread should be written to stop itself when a certain condition is met, and thus gracefully exit by ending the run() method. I admit, at first designing your threads like this will seem hard, but you'll get used to it. Jeff Walker