【问题标题】:is it necessary to synchronize I/O operation in AndroidAndroid中是否需要同步I/O操作
【发布时间】:2015-02-04 11:12:36
【问题描述】:

volley代码中,DiskBasedCache中的I/O操作(get/put)是同步的,不知道有没有必要。网络线程处理不同的 URL,因此将写入不同的文件。如果我们可以确保读取线程不会读取正在写入的文件,是否可以取消同步以获得更好的性能?

【问题讨论】:

  • f we can make sure reading thread won't read the files being writing 我认为可以删除synchronize

标签: android io synchronization


【解决方案1】:

同步允许对象安全地传递给不同的线程。请注意,在大多数情况下,没有 I/O 操作争用的同步不会成为瓶颈。

DiskBasedCache - 如果此缓存被多个线程使用以避免数据争用,则此处需要同步。

【讨论】:

    猜你喜欢
    • 2017-03-26
    • 1970-01-01
    • 2016-04-14
    • 2016-07-29
    • 1970-01-01
    • 2011-10-27
    • 2011-11-14
    • 1970-01-01
    相关资源
    最近更新 更多