Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

servlet

Status
Not open for further replies.

satellite03

IS-IT--Management
Dec 26, 2003
248
IN
i have a thread running in my servlet. i want to kill that thread from JSP . how can i kill it ?
 
You cannot really "kill" a thread. You should programme threads to exit on certain conditions. Perhaps you can tell us a little more about your specific problem ?

--------------------------------------------------
Free Database Connection Pooling Software
 
i started a thread inside servlet using thread.start(). Now i want to stop a thread using a condition. But how JSP can direct a servlet to stop the thread. My concern lies on the fact that servlet sends information to JSP ( client) but NOT VICE VERSA

so how a JSP can send signal to servlet to close down thread ?


 
Repeating your request will not help !

See ...

You cannot really "kill" a thread. You should programme threads to exit on certain conditions. Perhaps you can tell us a little more about your specific problem ?

--------------------------------------------------
Free Database Connection Pooling Software
 
ok, i understand that.

do u suggest to set a boolean var= false in JSP and then in servlet should i check its value using getparameter() to exit thread ? or what ? is this correct ?
i wanted to know the formula how to do it ?

 
If I were you, I would give the Thread access to the session object (pass it on on the constructor). Then, when your thread is doing whatever it does, make it check that a certain session parameter is a certain value. If not, exit the thread. Then you can control the thread from a JSP/servlet using the session to alter the parameter as appropriate.

--------------------------------------------------
Free Database Connection Pooling Software
 
ok.
JSP should contain
boolean var="true"
setAttribute("Acesses",var);





servlet have to check it by
boolean x = getAttribute("Acesses");

if (x)then
//stop
else
//do nothing.

i suppose, this is your plan.

 
Well, yes and no.

When you first create the Thread from the servlet, then thats it - its kicked off.

So if you need to stop the Thread from the servlet, the Thread needs to check whether it should continue processing - so it will need access to the session object in order to determine the value of "Acesses" or whatever your session value is ...

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top