提交 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,24 +34,28 @@ public abstract class FileBase extends FileChannel {
public abstract int write(ByteBuffer src) throws IOException;
@Override
public synchronized int read(ByteBuffer dst, long position)
public int read(ByteBuffer dst, long position)
throws IOException {
synchronized(this) {
long oldPos = position();
position(position);
int len = read(dst);
position(oldPos);
return len;
}
}
@Override
public synchronized int write(ByteBuffer src, long position)
public int write(ByteBuffer src, long position)
throws IOException {
synchronized(this) {
long oldPos = position();
position(position);
int len = write(src);
position(oldPos);
return len;
}
}
@Override
public abstract FileChannel truncate(long size) throws IOException;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论