Sunday, April 29, 2012

Re: [android-developers] How to force quit a Thread

What do you mean use flags?
The app hangs on lines that wait for an HTTP response, so i want to be able to just cut them off mid execution if I have to, i cant call check statements before and after.
Sorry, I do not know a whole lot about Threading.

On Monday, April 30, 2012 12:09:25 AM UTC-4, Ankita wrote:
stop(),destroy() etc. methods were deprecated by JDK versions, so must have not got support now. To stop thread, you should try to use flags, AFAIK.

On Mon, Apr 30, 2012 at 9:34 AM, Matt Clark <mrclark32493@gmail.com> wrote:
I am creating an app that sends various HTTP requests in seperate threads, while doing so brings up a loading screen. If the network request is taking longer then the user expects, I want them to be able to press the back button to force quit the thread, and dismiss the loading screen.
I have my thread set up as:

dataThread = new Thread(new Runnable() {
public void run() {
//...
//Networking Data and Handlers
//...
}
});
dataThread.start();

and where I want to force quit at onBackPressed() I have tried:

dataThread.stop();
dataThread.destroy();
dataThread.interrupt();

And none of them work, Android does not support stop(), or destroy(), and interrupt() does nothing to stop the thread. I do not care about exceptions as everything will be caught, I just want it to allow the user to resume doing what they want, if it hangs on requests, or even retry the request..

Any and all help is greatly appreciated.
~Matt

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate