Thread Queue for Android

I would like the work / task queue to be executed in a separate thread, but can only process one work at a time. So not at the same time.

Is there something built in for Android?

Thank,

EDIT: Work = get information from the database. After that, update the user interface with the extracted information.

+5
source share
3 answers

Have you checked java.util.concurrent.Executors? You can do something like this:

final static ExecutorService tpe = Executors.newSingleThreadExecutor();
...
tpe.submit(new Runnable() {
    @Override
    public void run() {
        // your work
    }
}):

This is not a specific android, it is part of jdk5.

From the doc:

, , . ( , - , , .) , . newFixedThreadPool (1) .

+13

, - , , IntentService. , , , .

, - , Java ExecutorService .

+3

All Articles