并发访问共享资源
我正在编写一个 Java 应用程序,用于访问作为共享资源存储在 Windows 服务器中的配置文件。据认为该应用程序有大约 500 名员工使用,因此它让我想到了并发性。
与实现相关,我通过 JCIFS 库访问文件,然后使用 inputStream 来读取和处理它。我猜 VM 与此无关,也与应用程序代码无关,所以我指出操作系统,在本例中是 Windows。
我不知道必须在何处或如何处理此问题,甚至不知道是否必须这样做。
另一方面,我们谈论的是远程文件,但如果该文件位于我们的文件系统中会发生什么?在这种情况下,VM 有话要说不是吗?一个文件可以打开多少个不同的输入流?和输出流?
我知道这些都不是具体问题,所以肯定很难回答。但任何帮助、评论或建议将不胜感激。
提前致谢!!
I am writing a Java application, that access to a configuration file stored as a shared resource in a Windows server. The app is thought to be used by around 500 employees, so it made me think about concurrency.
Related to the implementation, I access to the file through JCIFS library, then I used an inputStream to read and treat it. I guess VM have nothing to do with this nor application code, so I point out to the OS, in this case windows.
I don't know where or how must be treated this issue or even if I have to.
In other hand, we are talking about a remote file, but what happens if the file is located in our filesystem? In this case, VM has something to say hasn't it? How many different input streams can be opened over a file? and output streams?
I know that these are not concrete questions, so it must be difficult to answer them. But any help, comment or advices would be very appreciated.
Thanks in advance!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它仍然是一个输入流。
如果你愿意的话可以,但通常不会。
受操作系统限制,通常为数千。
相同。但是,如果您写入具有多个进程的文件,结果可能会一团糟,但您更有可能只从一个程序获得输出。 (但如果不重读你就不会知道哪个)
Its still an InputStream.
It can if you want to, but generally not.
Limited by the OS, usually thousands.
The same. But if you write to a file with more than one process the results could be a mess, but you are more likely to get the output from just one program. (But you wouldn't know which without re-reading it)
当您的应用程序使用该文件时,该文件是否会被写入?如果不是的话我无法想象这是一个问题。考虑多个编辑器同时打开同一个文件 - 没有坏处,没有犯规,直到有人进行更改并写入它。
Is the file going to be written to while your application is consuming it? If its not then I can't imagine it being a problem. Think about multiple editors with the same file open at the same time - no harm no foul till someone makes a change and writes it.