File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Java Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Threads" Watch "Java Threads" New topic

Java Threads

Pavan Kumar Dittakavi
Ranch Hand

Joined: Feb 12, 2011
Posts: 105

Hi Experts,

I have a small problem. I have 2 methods. MethodA and MethodB. If the user chooses to do someoperation on the UI, methodA will get called and finally methodB will get called and a thread is spawned from this methodB. But say suppose the control is in this thread spawned by methodB and the user selects som UI, then, the execution of thread of methodB should terminate instantly.

Is this possible. If yes, please provide me your views.

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Yes that is possible. Just interrupt the thread and in the Runnable of the thread check if the thread is interrupted.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
I agree. Here's the link:
subject: Java Threads
It's not a secret anymore!