`
yiyidog125
  • 浏览: 12744 次
  • 性别: Icon_minigender_1
  • 来自: 广州
最近访客 更多访客>>
社区版块
存档分类
最新评论

File Locks

阅读更多
Some scenarios on Windows
1. using a notepad to edit a txt file, at the same time, a java program is using BufferedReader to read it, what it read is the stale content.
2. when a lock is grabbed, trying to read file using bufferedReader will cause I/O exception, "java.io.IOException: The process cannot access the file because another process has locked a portion of the file".
3. two threads, writer periodically write content to a file(500ms), reader read content every 100ms, there are some times that reader read null.
so explicitly use file lock on windows makes a difference.
4. cannot get read lock from FileInputStream, use RandomAccessFile to get read lock.

and here is some comment from tryLock:
File locks are held on behalf of the entire Java virtual machine.
They are not suitable for controlling access to a file by multiple
threads within the same virtual machine.
2
0
分享到:
评论

相关推荐

    C8051F单片机产品编程器

    If the programmed hex file locks the Flash of the MCU, The MCU Production Programmer will not be able to serialize the device. Release Dates ------------- Production Programmer Version 2.50 - ...

    微软内部资料-SQL性能优化3

    Lesson 1: Concepts – Locks and Lock Manager 3 Lesson 2: Concepts – Batch and Transaction 31 Lesson 3: Concepts – Locks and Applications 51 Lesson 4: Information Collection and Analysis 63 Lesson 5:...

    locks-py:锁的Python实现,这是一种基于lox编程语言的命令式,动态类型化,面向过程的脚本语言

    锁具 锁是一种基于语言的命令式,动态类型化,面向过程的脚本语言。 Locks-py是python的锁实现。... 要运行程序,请通过File -> Open打开一个锁定文件,然后从菜单栏中选择Run -> Run(debug) 。 有关更多详细

    Advanced.PDF.Password.Recovery.PRO.v2.12

    user-level one locks the file so the password is requiored to open/view the file. If only "owner" password is set, decryption is being done instantly; decrypted file can be opened in any PDF viewer ...

    Bootstrap_FileUpload4.3.9+Drapper+IOC+MVC

    Bootstrap_FileUpload4.3.9+Drapper+IOC+MVC ,包含...)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO

    Unlocker(解锁顽固文件)

    Select the locks and click Unlock and you are done. It is recommended to Unlock wisely and to close open processes locking files or folder if any, but if only Explorer.exe is the culprit, do not ...

    KeePass A lightweight and easy-to-use password manager Windows

    KeePass Password Safe is a free, open source, ... KeePass puts all your passwords in a highly encrypted database and locks them with one master key or a key file. As a result, you only have to remem

    Windows读写Ext2/Ext3/Ext4文件系统

    Supports features which are specific to the I/O-system of Windows: Byte Range Locks, Directory Notfication (so the Explorer updates the view of a directory on changes within that directory), Oplocks ...

    Android Platform Developer‘s Guide.doc

    Building a APK that depends on a static .jar file 16 Building a APK that should be signed with the platform key 16 Building a APK that should be signed with a specific vendor key 17 Adding a prebuilt ...

    Absolute Database for D7

    000 30,000 Database size 32 TB (also limited by file system and OS) 32 TB (also limited by file system and OS) Identifier length (in characters) 255 255 Locks per connection 2,147,483,647 N/A Rows per...

    mtrr.rar_The Guard

    Do not use an include-guard. This file is included once to declare the locks and once in win32 to actually do the runtime initialization.

    UNIX环境高级编程英文第三版+源码

    4.25 Summary of File Access Per mission Bits 140 4.26 Summary 140 Chapter 5. Standard I/O Library 143 5.1 Introduction 143 5.2 Streams and FILE Objects 143 5.3 Standard Input, Standard Output, and ...

    使用VLC1.0.5进行RTSP2TS转码

    sed -e 's/define\s*_POSIX_SPIN_LOCKS\s*/define _POSIX_SPIN_LOCKS -1 \/\/ wrong: /g' -i /usr/include/bits/posix_opt.h 4. 重试make出现error: `AFS_SUPER_MAGIC' undeclared: file.c:52:28: linux/magic.h: ...

    case labs 1~7

    cse的七个lab lab1 Inode Manager lab2 Basic File Server lab3 RPC Hand-on lab4 Lock Server lab5 Cache for Locks lab6 Cache for Extends lab7 RPC

    MS-DOS 5.0

    In this file the following topics are covered: 1. Introduction 2. Solving Setup Problems 2.1 Priam and Everex Hard Disks 2.2 SyQuest Removable Hard Disk 2.3 Bernoulli Drive 2.4 Disk Manager 2.5...

    Windows System Programming, 4th Edition

    Windows System Programming, Fourth Edition, now contains ...* Windows performance-enhancing API features available starting with Windows Vista, such as slim reader/writer locks and condition variables

    最完整的Toad For Oracle使用手册

    Third Party File Based Source Control 694 Team Coding 697 Status in the Editor Status Bar or Team Coding Viewer Status Column 707 Detailed File Properties 708 Checking Objects and Scripts in and out ...

    UNIX Network Programming Volume 2(Unix网络编程卷2英文版)

    8.2 obtaining and releasing read-write locks 178 8.3 read--write lock attributes 179 8.4 implementation using mutexes and condition variables 179 8.5 thread cancellation 187 8.6 summary 192 ...

    JDK_1_6 API

    java.util.concurrent.locks 为锁和等待条件提供一个框架的接口和类,它不同于内置同步和监视器。 java.util.jar 提供读写 JAR (Java ARchive) 文件格式的类,该格式基于具有可选清单文件的标准 ZIP 文件格式。 ...

    PLock-简单高效的跨进程锁,支持读写锁分离.zip

    // OR you can also use it as a file lock:// PLock pLock = new PLock(file);pLock.lock();  try { // to do something...} catch (Exception e) { // errors} finally {  pLock....

Global site tag (gtag.js) - Google Analytics