java - What if the computation inside a listener is slow than the listener's update? -


i new android programmer. , implementing algorithm within sensor listener, each time sensor data has been received, computations base on newly received sensor data, code this:

class somelistener implements somesensorlistener {      public void onreceive(item state) {         // computation here, , make change ui     } } 

and wondering question: if computation slower sensor data update frequency, when newest sensor data arrives, last round of computation has not been finished? result in problem?

thank in advance answer!

there's 2 case scenarios:

if callback asynchronous spawn new thread every time method called. means many of these methods can co-exist @ same time. if callback synchronous spawn in same thread (this case). in android means looper (http://developer.android.com/reference/android/os/looper.html) handle message previous message has finished. if computation of method slower rate @ new messages added queue of looper, may throw kind of exception.

are sure computation takes more time rate of callbacks?


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -