This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Not able to stop execution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Not able to stop execution" Watch "Not able to stop execution" New topic

Not able to stop execution

Happy S Singh
Ranch Hand

Joined: Nov 14, 2011
Posts: 56
I am not able to stop the execution of the thread.I want to stop the execution while it is executing or on the button click event based on the thread id passed. I am trying below code

Steve Luke

Joined: Jan 28, 2003
Posts: 4181

The key here is what happens in upload(). Setting the finished flag does not stop upload() from executing, it just prevents it from running again. If you want to make sure upload() stops before it completes there needs to be some way to interrupt the execution of that code. Since you don't show that code it is hard to say how you should do that.

Happy S Singh
Ranch Hand

Joined: Nov 14, 2011
Posts: 56

My whole class with upload method.Guide me

Henry Wong

Joined: Sep 28, 2004
Posts: 20055

Happy S Singh wrote:
My whole class with upload method.Guide me

Steve gave you the answer -- and even a direction on making it do what you want.

Ignoring the answer, and dumping more code (that doesn't add to the topic) is not really very useful here.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Have you checked out Aspose?
subject: Not able to stop execution
jQuery in Action, 3rd edition