开发者

Android Sync needed in writing files and

I have an android application that runs a thread thar reads the sensor values and writes them to a file after 500ms.The values of sensors(accelerometer) are declared as global and change inside the sensorChange() event.I do not have a lock on read and write operations.Should I have some kind of a synchronized mechanism or is i开发者_运维问答t fine as one event performs the reading and the other writing.

eg,For Accelerometer I have a global variable xA,yA,zA,which are written into file 4 times every second and are updated in sensorChangeEvent().


If you have 2 threads - one reads a variable and another writes to the same variable, then you have to synchronize the access

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜