This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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: 104

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
jQuery in Action, 3rd edition