public class WriteThread extends Thread{
@Override
public void run() {
RandomAccessFile randomAccessFile = new RandomAccessFile(fileName, "rwd");
randomAccessFile.seek(threadPosition);
byte[] buffer = new byte[1024 * 8];
randomAccessFile.write(buffer, 0, threadLength);
}
}
In my code, each thread writes data to the same file through respective RandomAccessFile object.Does that need to be synchronized? Sorry for my poor English.