并发访问共享资源

发布于 2024-12-06 14:23:38 字数 418 浏览 0 评论 0原文

我正在编写一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哎呦我呸! 2024-12-13 14:23:38

另一方面,我们谈论的是远程文件,但如果该文件位于我们的文件系统中会发生什么?

它仍然是一个输入流。

在这种情况下,VM 有话要说不是吗?

如果你愿意的话可以,但通常不会。

一个文件可以打开多少个不同的输入流?

受操作系统限制,通常为数千。

和输出流?

相同。但是,如果您写入具有多个进程的文件,结果可能会一团糟,但您更有可能只从一个程序获得输出。 (但如果不重读你就不会知道哪个)

In other hand, we are talking about a remote file, but what happens if the file is located in our filesystem?

Its still an InputStream.

In this case, VM has something to say hasn't it?

It can if you want to, but generally not.

How many different input streams can be opened over a file?

Limited by the OS, usually thousands.

and output streams?

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)

雨后咖啡店 2024-12-13 14:23:38

当您的应用程序使用该文件时,该文件是否会被写入?如果不是的话我无法想象这是一个问题。考虑多个编辑器同时打开同一个文件 - 没有坏处,没有犯规,直到有人进行更改并写入它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文