Hi,

I'm hoping that someone could provide me with a bit of advice around
managing the threads in my application.

I'm implementing an application for android that consists of several
activities. All work in the application is done using a series of
"tasks", which are atomic units of work that are processed by what is
basically a threadpool. The threadpool is a singleton, so anywhere
within the application, I can do something like:

LoginTask login = new LoginTask(credentials)
BackgroundProcess.getInstance().addTask(login);

This fires off a message to our server asking to authenticate the
user. The application then polls for a resonse and handles it
accordingly when it receives it. This is a pretty basic example. There
are many other asynchronous tasks occurring within the application.

My confusion/uncertainty revolves around initializing and shutting
down the threadpool singleton. There appears to be no way to know when
the "application" is shutdown, since an application is simply a bunch
of interacting activities. I know when a given activity is destroyed
or stopped or paused, but that doesn't mean that the application is
shutdown.

I've read up on services. Might this be the way to go? Implement a
service that starts the threadpool in onCreate and that shuts it down
in onDestroy? My understanding is that the service can go on running
long after all activities have been destroyed. I may not quite
understand this correctly, though.

Any advice is appreciated and I'd be happy to provide more detail if
clarification is needed.

Thanks,
Matt

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

Reply via email to