I'm having a bit of trouble understanding how to use the Looper
prepare()
/loop()
/quit()
logic.
I have three threads: one is the UI thread, one is a game logic thread and the last is a network communication thread (a background thread, lives only while being used).
The game thread has many dependencies on the results of the network calls, so I wanted to spin the network thread off of the game thread and have a Handler
post the result back.
Of course, since the UI thread is not involved I need to call Looper.prepare()
... somewhere. I thought it should be called in the game thread, but I can't do that because loop()
takes it over.
How do I go about posting back to the game thread from network thread with my handler?