Multithreaded access to file

后端 未结 7 949
[愿得一人]
[愿得一人] 2020-12-30 08:04

We have a multi threaded java program. Multiple-threads will write to a file, and one thread will read from that file. I am looking for some design ideas. Is synchronization

7条回答
  •  太阳男子
    2020-12-30 08:13

    If being synchronous isn't important, you could have your writer running in its own thread, and allow other threads to queue up writes to the file. Although I think the first thing to consider is whether writing to a file is really what you want to do. Especially in high-traffic situations, having a lot of disk I/O may not be very efficient.

提交回复
热议问题