File Access Strategy in a Multi-Threaded Environment (Web App)

前端 未结 5 1091
南笙
南笙 2021-01-05 16:25

I have a file which is an XML representation of some data that is taken from a Web service and cached locally within a Web Application. The idea being is that this data is <

5条回答
  •  悲&欢浪女
    2021-01-05 17:04

    OK, I have been working on this and ended up creating a stress-test module to basically hammer the crap out of my code from several threads (See Related Question).

    It was much easier from this point on to find holes in my code. It turns out that my code wasn't actually far off, but there was a certain logic path that it could enter in to which basically caused read/write operations to stack up, meaning if they didn't get cleared in time, it would go boom!

    Once I took that out, ran my stress test again, all worked fine!

    So, I didn't really do anything special in my file access code, just ensured I used lock statements where appropriate (i.e. when reading or writing).

提交回复
热议问题