Dalvik VM & Java Memory Model (Concurrent programming on Android)

I haven’t read your question completely,
but first of all do not use volatile, even opengles coders do not use it for different ui vs renderer threads.

Use volatile if and only if one thread writes (say to some class’ static property)
and other reads, even then you have to synchronize, read this for some good ways to handle counts

How to synchronize a static variable among threads running different instances of a class in java?

  1. always use synchronize
  2. do not jump at large projects for such difficult topics like concurrent programming
  3. go through android samples on games where they have discussed the concept of runnables,
    handlers, and exchanging messages b/w threads (UI THREAD AND RENDERER THREAD).

Leave a Comment