Yes, indeed there are potential synchronization issues. I've done some of 
this myself. 

You may want to use something like: 
java.util.concurrent.locks.ReentrantLock;

Lock, draw to, and then release. 

Lock, draw from, and then release. 

This can work if you are sure you are locking it only for short periods. 
Don't wait for any network or database traffic while the lock is on. 

The UI will block in onDraw if your worker task is drawing. If the draw 
operation takes 10 milliseconds, this isn't bad. If it takes four seconds 
it will be bad and cause an ANR.   

There may be other ways of handing it also, but yes, what you are doing now 
is not very safe. 

Nathan 


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to