Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Close Browser window stop thread  RSS feed

 
Chinni Bujji
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

If we close the browser window can we write the code to stop the thread that was running on that page
Any ideas on this how to correlate the user actions

Thanks

 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A thread running on a page?? Are you talking about applets, asynchronous calculations on a server or what?
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's an applet (the only case where the thread is actually running in a browser) then closing the browser will terminate the entire JVM. All the threads will end as a result of that. You don't have to write any code to help that process along.
 
Chinni Bujji
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a thread running in a jsp
I have a button which clicked will start the thread and a stop button to stop the thread

but if the user forgot to click the stop the thread button and if the user closes the browser the thread is still running
so i want to know if there is any mechanism which i can use to capture the user activity and stop the thread

thanks in advance
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WHY did you want to start a Thread inside a JSP?

JSP are for presentation - I cant think of any reason to start a Thread in one.

Bill
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chinni Bujji wrote:but if the user forgot to click the stop the thread button and if the user closes the browser the thread is still running
so i want to know if there is any mechanism which i can use to capture the user activity and stop the thread


Not really. And you can't capture the "user activity" where the user goes home for the night, leaving the browser still open, either. As William Brogden suggested, you might want to review your design. If letting users create unregulated threads is a problem, then consider not letting them do that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!