简体   繁体   English

FileService中的变量锁是什么意思?

[英]what does the variable lock mean in FileService?

What does the variable boolean lock mean in FileService.html#openReadChannel ? 布尔值锁定变量在FileService.html#openReadChannel中是什么意思?

When I tried it with false I got an illegal state exception and when with true I din't get any. 当我尝试使用false时,我得到了一个非法的状态异常,当使用true时,我什么也没有。 I was trying to upload a file. 我正在尝试上传文件。

What does this argument do ? 这个论点是做什么的? I have read the doc but haven't understood it. 我已阅读该文档,但尚未理解。

According to that page, it says 根据该页面,它说

lock - should the file be locked for exclusive access? 锁定-是否应锁定文件以进行独占访问?

So it basically asks if you should be the only one who can access it. 因此,它基本上询问您是否应该是唯一可以访问它的人。

If you use false then you'll probably try to write to it when someone else has access. 如果使用false那么您可能会在其他人有权访问时尝试对其进行写入。 I would assume that in almost all cases, you'll want true , since generally only one process writes to a file at a time. 我假设几乎在所有情况下都需要true ,因为通常一次只有一个进程写入文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM