在Android的并行文件访问 [英] Concurrent file access in Android

查看:100
本文介绍了在Android的并行文件访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道很多操作系统进行某种形式的锁定上的文件系统,以prevent不一致的意见。是否有任何保证,Java和/或Android做出的文件访问线程安全?我想知道尽可能多关于这个问题,可能之前我继续前进,写并发code自己。

I know that many OSes perform some sort of locking on the filesystem to prevent inconsistent views. Are there any guarantees that Java and/or Android make about thread-safety of file access? I would like to know as much about this as possible before I go ahead and write the concurrency code myself.

如果我错过了得到的回答类似的问题,请随时关闭该线程。谢谢你。

If I missed a similar question that was answered feel free to close this thread. Thanks.

推荐答案

Android基于Linux之上,因此继承了Linux的文件系统中的语义。除非你明确地锁定文件,多个应用程序和线程可以打开进行读/写访问。除非你真的需要跨进程的文件同步,我会建议使用普通的Java同步原语的仲裁访问该文件。

Android is built on top of Linux, so inherits Linux's filesystem semantics. Unless you explicitly lock a file, multiple applications and threads can open it for read/write access. Unless you actually need cross-process file synchronization, I would suggest using normal Java synchronization primitives for arbitrating access to the file.

这篇关于在Android的并行文件访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆