Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Interrupt an operation in Swing Application  RSS feed

 
Ajay Njallacattu
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can anyone suggest a way to Interrupt an operation in Swing Application. For example one operation in the application is taking more time. Then I need to stop this particular operation and continue with others.

Thanks a lot in advance for the help.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have an operation which takes a long time, you ought to start a new Thread. Find out about the SwingWorker class which does that.

I don't think you can interrupt the operation from the screen, however.
 
Ajay Njallacattu
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the info..

Do we have any other approach other than SwingWorker. I just need to check the feasibility of the options we have to implement this.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ajay Njallacattu:

Do we have any other approach other than SwingWorker.


What you essentially need is a multithreaded approach. You put your tasks on different threads so you have the flexibility of stopping any of them whenever you want.
Check this out for more information
http://java.sun.com/docs/books/tutorial/essential/concurrency/
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!