Thread help with Android game
Posted
by Ciph3rzer0
on Stack Overflow
See other posts from Stack Overflow
or by Ciph3rzer0
Published on 2010-03-13T21:22:58Z
Indexed on
2010/03/13
21:25 UTC
Read the original article
Hit count: 171
I need some help dealing with three Threads in Android
One thread is the main thread, the other is the GLThread, and the other is a WorkerThread I created to update the game state.
The problem I have is they all need to access the same LinkedList of game objects. Both the GLThread and my WorkerThread only read from the LinkedList, so no problem there, but occasionally I have the main thread adding in another game object to the list.
How can I manage this? I tried using synchronized in front of the functions involved but it really slows down the application.
For some reason, just catching the errors and not rendering or updating the game state that frame, causes it to start lagging permanently.
Anyone have any great ideas?
© Stack Overflow or respective owner