Dude... U can never stop a thread... as the methods are deprecated
u can assign the thread object to null. so that the object will be garbage collected :) Abu On Mon, Aug 31, 2009 at 5:44 PM, jsdf <[email protected]> wrote: > > Does anyone out there have thoughts on this? > Thanks, > jsdf > > On Aug 28, 5:56 pm, jsdf <[email protected]> wrote: > > Hi Android experts, > > I have a tricky question that I would like some advice on. > > > > I have a thread that does a large amount of network and database > > work. E.g.: > > > > new Thread(new Runnable() { > > public void run() { > > String largeData = getLargeDataFromServer(); > > Object largeObject = xmlParser.parseFromXml(largeData); > > saveLargeObjectToDatabase(); > > putLargeDataToSecondServer(); > > } > > > > }).start(); > > > > The problem I have is that I need to stop this thread at any point. > > It does not need to stop absolutely immediately, but given limited > > network and memory on the phone, the sooner I can stop it the better. > > > > I currently am testing and stopping with a method similar to this: > > > > new Thread(new Runnable() { > > public void run() { > > if (shouldStop) return; > > String largeData = getLargeDataFromServer(); > > if (shouldStop) return; > > Object largeObject = xmlParser.parseFromXml(largeData); > > if (shouldStop) return; > > saveLargeObjectToDatabase(); > > if (shouldStop) return; > > putLargeDataToSecondServer(); > > } > > > > }).start(); > > > > This makes me very uncomfortable, and litters my code with these > > shouldStop statements. Furthermore, if the system is in any of the > > four long functions, that function has to complete before the test can > > actually happen. > > > > I notice that there is a Thread.stop(), but the comments warn against > > using it. > > > > Does anyone have suggestions on how to reconfigure the thread so I can > > stop relatively quickly and regardless of whether execution is in one > > of its subfunctions? > > > > Thanks so much in advance, > > jsdf > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

