• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Alternating between worker threads while communicating with UI thread via handleMessage

I have a UI Thread and two other Threads: Player 1 and Player 2. What I need to do is to alternate execution between Threads. Join doesn't work as it stops the execution of the current thread because of which the handleMessage() method in the UI Thread isn't called. What I basically want is to start Player1 thread from the main UI Thread, run it to completion (during which it also calls the UI thread's handleMessage()), then switch to Thread 2, run this thread to completion, switch back to thread 1 and so forth. How do I do this? I cannot use AsyncTasks.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones