摘要: 文件加锁:文件加锁机制允许我们同步访问某个作为共享资源的文件。public class Test { public static void main(String[] args) throws IOException { FileOutputStream fos = new FileOutputStream("test.txt"); /* * 通过tryLock 或者 lock 获得整个文件的FileLock * tryLock(position, size, shared) 对文件进行部分加锁 */ FileLock fileLock = fos.getChannel() 阅读全文
posted @ 2013-11-27 22:14 E_star 阅读(537) 评论(0) 推荐(0)