Reputation: 44807
What is the correct, efficient, way for threads (within a service) to communicate under Android?
I have looked at Intents (serialization overhead), HandlerThreads and Loopers (bundling overheads).
A receiving thread should have have (synchronized) queue(s) to which objects (of types known at compile time) can be added.
I have previously written such functionality for JavaME, but I was under the impression that Android would have a "standard" efficient way of communicating between threads, using compile-time-known types.
Am I missing something fundamental? (I do not have much recent Java experience beyond JavaME/1.3.)
Upvotes: 0
Views: 72
Reputation: 52956
The native way to send messages to a thread is Handler
's. If that doesn't meet your requirements (which are?), you can implement a thread messaging system yourself using Java primitives and/or java.util.concurrent
classes.
Upvotes: 1