提交 79c7b389 authored 作者: Noel Grandin's avatar Noel Grandin

hide the synchronization inside these methods

so we don't get warnings about the overriding methods also needing to be
synchronized, which is not the case
上级 4f0d619b
...@@ -34,23 +34,27 @@ public abstract class FileBase extends FileChannel { ...@@ -34,23 +34,27 @@ public abstract class FileBase extends FileChannel {
public abstract int write(ByteBuffer src) throws IOException; public abstract int write(ByteBuffer src) throws IOException;
@Override @Override
public synchronized int read(ByteBuffer dst, long position) public int read(ByteBuffer dst, long position)
throws IOException { throws IOException {
long oldPos = position(); synchronized(this) {
position(position); long oldPos = position();
int len = read(dst); position(position);
position(oldPos); int len = read(dst);
return len; position(oldPos);
return len;
}
} }
@Override @Override
public synchronized int write(ByteBuffer src, long position) public int write(ByteBuffer src, long position)
throws IOException { throws IOException {
long oldPos = position(); synchronized(this) {
position(position); long oldPos = position();
int len = write(src); position(position);
position(oldPos); int len = write(src);
return len; position(oldPos);
return len;
}
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论