Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
每次用户访问我的网站页面时,都会xml从一个预定义文件中写入和删除几个元素。
xml
最终会出现一种情况,在同一个文件上几乎同时进行读取和写入操作。在这种情况下如何处理并发?是否有一个特殊的基类库类可以为我处理它?
XML 文件不会为您执行此操作。您可以设置一个同步对象:最简单的方法是拥有一个访问文件并使用锁定关键字的通用函数。使用 Mutex 进行进程间同步。
然而,这将是一个潜在的瓶颈。
可能是时候开始使用数据库了。