05-18-2011 06:39 PM
I have a class(GetHTTPData) that implements a thread wich makes a http connection to update data on recordstore.
I want to launch this thread every minute.
How should I do it? with a Timer launching GetHTTPData?
05-18-2011 08:12 PM
As I'm newbie on java I'm afraid to launch a bunch of threads and shutdown the app.
As far as I know the timer itself creates a new thread and it will launch a new thread every minute.
What are the measures that I must take in order to guarantee the App stability?
05-19-2011 04:48 AM
While I agree with KraKra, and in fact that is probably how I would do it, if your Thread is going to finish in a minute, there will only ever be one outstanding. So not really a problem.
From memory you can catch the "Too many Threads" Exception on the start anyway if you see it.
But my biggest issue with this is the need to start networking activity every minute. That sounds like polling and polling is bad for battery life and typically bad for overuse of network data. So I would review this design approach.
05-19-2011 06:13 PM
I don´t know how long will last the Thread. I assume that the operation sometimes could take longer, and then I could have several threads on execution.
I saw on another post that the While loop is not time accurate...that was the fact that lead me to use a Timer...
Peter, if you had to call a WebService that querys a Database wich is being upgraded at every second, and you wanted to refresh your app with new data, how would you do that?
Thks a lot for your help!