Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Square Tape file backed queue be used from the main thread in android?

Square has an open source project name Tape http://square.github.io/tape/ that implements a persistent file backed queue. All of the examples seem to indicate that objects can be added to the queue from the main thread. However, every other best practice for android seems to indicate that doing I/O on the main thread is just playing chicken with ANRs.

Is the Square Tape file backed queue designed to be used from the main thread? If so, what makes it reliably safe to used from the main thread without the fear of an ANR vs any other form of I/O?

like image 862
apschexn Avatar asked Nov 11 '22 13:11

apschexn


1 Answers

If you take a look inside the examples on http://square.github.io/tape/ , basically you should use a service within a thread on each Task inherited class for do the job, since Task has the concept of something that could be executed.

If you want, you could do some explorations with HandlerThread, AsyncTask or even Executors and test which of those fits better upon your needs.

like image 99
william gouvea Avatar answered Nov 14 '22 23:11

william gouvea